Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

C program to convert meter to centimeter

C
#include <stdio.h>

int main() {
    double meters, centimeters;

    printf("Enter the length in meters: ");
    scanf("%lf", &meters);

    centimeters = meters * 100;

    printf("%.2lf meters is equal to %.2lf centimeters.\n", meters, centimeters);

    return 0;
}

In this program, we declare variables for meters and centimeters. We prompt the user to enter the length in meters using printf and scanf.

Next, we calculate the equivalent length in centimeters by multiplying the meters value by 100, as there are 100 centimeters in one meter.

Finally, we print the original meters value and the converted centimeters value using printf with the format specifier %.2lf to display the values with two decimal places.

Please note that %lf is used for double data types in scanf and printf functions to correctly read and display decimal values.

Output
Enter the length in meters: 5
5.00 meters is equal to 500.00 centimeters.