C Program to Convert Kilometer to Meter Centimeter and Millimeter

In this tutorial, i am going to show you how to convert kilometers to meters, centimeters and milimeter in the c program.

Algorithm to Convert Kilometer to Meter Centimeter and Millimeter

Follow the below given algorithm to write a c program to convert kilometers to Meters, Centimeters, and Millimeters; as follows:

  • Start program.
  • Take input kilometer and store in it variable.
  • Convert kilometers to meters, centimeter and milimeter by using following formula
    • Meter = Kilometer * 1000.0;
    • Centimeter = Kilometer * 100000.0;
    • Millimeter = Kilometer * 1000000.0;
  • Print meter, centimeter and milmeter.
  • Stop program.

C Program to Convert Kilometer to Meter Centimeter and Millimeter

/* C Program to Convert Kilometer to Meter Centimeter and Millimeter */
 
#include <stdio.h>
 
int main()
{
  	float Millimeter, Centimeter, Meter, Kilometer;
 
 	printf("\n Please Enter the Length in Kilometers (km)  :  ");
  	scanf("%f", &Kilometer);
  
  	Meter = Kilometer * 1000.0;
  	Centimeter = Kilometer * 100000.0; 	
  	Millimeter = Kilometer * 1000000.0; 	
 
    printf("\n %.2f Kilometers  = %.2f Meters", Kilometer, Meter);
    printf("\n %.2f Kilometers  = %.2f Centimeters", Kilometer, Centimeter);
    printf("\n %.2f Kilometers  = %.2f Millimeters", Kilometer, Millimeter);
  
   	return 0;
}

The output of the above c program; as follows:

Please Enter the Length in Kilometers (km)  :  1
1.00 Kilometers  = 1000.00 Meters
 1.00 Kilometers  = 100000.00 Centimeters
 1.00 Kilometers  = 1000000.00 Millimeters

Be First to Comment

Leave a Reply

Your email address will not be published.