Home / Programs / C program to convert centimeter to meter and kilometer
🚀 Programming Example

C program to convert centimeter to meter and kilometer

👁 9,087 Views
💻 Practical Program
📘 Step Learning

In this program we will convert centimeter to meter and kilometer. First we will read length in centimeter from user. then using formula we will convert centimeter to meter and kilometer.

Flow chart

C program to convert centimeter to meter and kilometer

💻 Program Code

/**
 * 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;
} 
                        

🖥 Program Output

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

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.