luc047.c¶
Problem Statement
Define a function that receives weight of a commodity in kilograms and returns the equivalent weight in Grams, Tons and pounds. Call this fuction from main() and print the results in main()
Metadata¶
| Property | Detail |
|---|---|
| Author | Amit Dutta (amitdutta4255@gmail.com) |
| License | MIT |
Actions¶
💡 You can print or save this file by opening Raw and using your browser.
Source Code¶
#include <stdio.h>
void convertWeight(double, double *, double *, double *);
int main()
{
double weightGram, weightPound, weightKG, weightTON;
printf("Enter the weight of the comodity in Kilogram(s): ");
scanf("%lf", &weightKG);
convertWeight(weightKG, &weightGram, &weightPound, &weightTON);
printf("\n%g Kilogram(s) = %.04f Gram(s)"
"\n%g Kilogram(s) = %.04f Pound(s)"
"\n%g Kilogram(s) = %.04f TON(s)",
weightKG, weightGram, weightKG, weightPound, weightKG, weightTON);
return 0;
}
void convertWeight(double weightKG, double *weightGram, double *weightPound, double *weightTON)
{
*weightGram = weightKG * 1000.0;
*weightPound = weightKG * 2.2046226218;
*weightTON = weightKG / 1000.0;
}