bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

luc047.c (1146B)


      1 /*
      2  * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 12 Dec 2025
      3  * Repo: https://github.com/notamitgamer/bsc
      4  * License: MIT
      5  */
      6 
      7 /* Define a function that receives weight of a commodity in kilograms
      8 and returns the equivalent weight in Grams, Tons and pounds. Call
      9 this fuction from main() and print the results in main()
     10 */
     11 /* Let Us C, Chap- 9, Page - 163, Qn No.: C(b) */
     12 
     13 #include <stdio.h>
     14 
     15 void convertWeight(double, double *, double *, double *);
     16 
     17 int main()
     18 {
     19     double weightGram, weightPound, weightKG, weightTON;
     20     printf("Enter the weight of the comodity in Kilogram(s): ");
     21     scanf("%lf", &weightKG);
     22 
     23     convertWeight(weightKG, &weightGram, &weightPound, &weightTON);
     24     printf("\n%g Kilogram(s) = %.04f Gram(s)"
     25            "\n%g Kilogram(s) = %.04f Pound(s)"
     26            "\n%g Kilogram(s) = %.04f TON(s)",
     27            weightKG, weightGram, weightKG, weightPound, weightKG, weightTON);
     28     return 0;
     29 }
     30 
     31 void convertWeight(double weightKG, double *weightGram, double *weightPound, double *weightTON)
     32 {
     33     *weightGram = weightKG * 1000.0;
     34     *weightPound = weightKG * 2.2046226218;
     35     *weightTON = weightKG / 1000.0;
     36 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror