C program to convert centimeter to meter and kilometer

C Programming Language Fundamentals of C Language (Article) Fundamentals of C Language (Program)

8941

Program:

/**
 * C program to convert centimeter into meter and kilometer
 */
 
#include"stdio.h"
 
int main()
{
    float cm, meter, km;
 
    // Read length in centimeter from user
    printf("Enter length in centimeter: ");
    scanf("%f", &cm);
 
    // Convert centimeter into meter and kilometer
    meter = cm / 100.0;
    km = cm / 100000.0;
 
    printf("Length in Meter = %.2f m\n", meter);
    printf("Length in Kilometer = %.2f km \n", km);
 
    return 0;
} 

Output:

Enter length in centimeter: 10000
Length in Meter = 100.00 m
Length in Kilometer = 0.10 km
Press any key to continue . . .

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.