luc047.c (1010B)
1 /* Define a function that receives weight of a commodity in kilograms 2 and returns the equivalent weight in Grams, Tons and pounds. Call 3 this fuction from main() and print the results in main() 4 */ 5 /* Let Us C, Chap- 9, Page - 163, Qn No.: C(b) */ 6 7 #include <stdio.h> 8 9 void convertWeight(double, double *, double *, double *); 10 11 int main() 12 { 13 double weightGram, weightPound, weightKG, weightTON; 14 printf("Enter the weight of the comodity in Kilogram(s): "); 15 scanf("%lf", &weightKG); 16 17 convertWeight(weightKG, &weightGram, &weightPound, &weightTON); 18 printf("\n%g Kilogram(s) = %.04f Gram(s)" 19 "\n%g Kilogram(s) = %.04f Pound(s)" 20 "\n%g Kilogram(s) = %.04f TON(s)", 21 weightKG, weightGram, weightKG, weightPound, weightKG, weightTON); 22 return 0; 23 } 24 25 void convertWeight(double weightKG, double *weightGram, double *weightPound, double *weightTON) 26 { 27 *weightGram = weightKG * 1000.0; 28 *weightPound = weightKG * 2.2046226218; 29 *weightTON = weightKG / 1000.0; 30 }