C Program to Convert Centimeter to Meter and Kilometer

C Program to Convert Centimeter to Meter and Kilometer

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

Algorithm to Convert Centimeter to Meter and Kilometer

Use the following algorithm to write a c program to convert centimeters to meters and kilometers; as follows:

  • Start program.
  • Take input centimeter and store in it.
  • Convert centimeter to meters and kilometers by using this two formula
    • meter = cm / 100.0;
    • km = cm / 100000.0;
  • Print meter and kilometer.
  • Stop program.

C Program to Convert Centimeter to Meter and Kilometer

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

The output of the above c program; as follows:

Please Enter the Length in Centimeters  :  1000
Length in Meters  = 10.0000
Length in Kilometers   = 0.0100

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 *