C Program to Convert Kilometer to Meter Centimeter and Millimeter

C Program to Convert Kilometer to Meter Centimeter and Millimeter

C program to convert kilometers to centimeters, meters, and millimeters; Through this tutorial, we will learn how to convert kilometers to meters, centimeters and milimeter in the c program.

Algorithm to Convert Kilometer to Meter Centimeter and Millimeter

Use the following 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

Recommended C Programs

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *