luc047.c ​
Metadata ​
- Author — Amit Dutta (amitdutta4255@gmail.com)
- Last updated — 12 Dec 2025
- License — MIT
Problem Statement ​
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()
Source Code ​
Printing the code
To print this file, open it on GitHub and click Raw before printing, or use the Download Raw button above and print directly from that page.
c
#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;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24