Learn about C Program to Convert Kilograms to Grams in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
C Program to Convert Kilograms to Grams
That is, kg1000 (kg is the user-supplied weight in kilograms) is initialized to any variable, say g. (holds equivalent weight in gram) At the end of the program, print the value of g. For example, if a user provides their weight in kilograms as 12.43, kg1000, 12.43*1000, or 12430 is initialized to g.
Program:
#include<stdio.h>
int main()
{
double kg, gm;
printf("Enter Kilograms: ");
scanf("%lf",&kg);
gm = 1000*kg;
printf("Grams=%.2lf\n",gm);
return 0;
}
Output:
Enter Kilograms: 10
Grams=10000.00
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Codes :
C Program to Convert Inches to Centimetre
C Program to Find Range of Data Types