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

AuthorDevendra Dode

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including 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. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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