[Tutorial 7] 7.Convert given value in Meter to centimeter.
#include <stdio.h>
int main()
int main()
{
double meters, centimeters;
/* Input length in meters*/
printf("Enter length in meters: ");
scanf("%lf", &meters);
/* Convert meters to centimeters*/
centimeters = meters * 100;
/* Display the result*/
printf("%.2f meters is equal to %.2f centimeters.\n", meters, centimeters);
return 0;
}
/* Input length in meters*/
printf("Enter length in meters: ");
scanf("%lf", &meters);
/* Convert meters to centimeters*/
centimeters = meters * 100;
/* Display the result*/
printf("%.2f meters is equal to %.2f centimeters.\n", meters, centimeters);
return 0;
}
This C program prompts the user to input a length in meters, reads the input, then converts the length to centimeters by multiplying it by 100 (since 1 meter equals 100 centimeters). Finally, it displays the converted length in centimeters with two decimal places.
Comments
Post a Comment