Convert Centimetre into Metre in C Program | Kilometre
ADVERTISEMENTS
Convert centimetre into metre in C program.
In this article, you will learn how to convert centimetre into metre in C program.
Example
Enter the length in centimeter::
100
Length in Meter = 1.000000 meter
Length in Kilometer = 0.001000 kilometer
Standard Formula
1m = 100cm
1km = 100000cm
You should have knowledge of the following topics in c programming to understand this program:
- C
main()
function - C
printf()
function
Source Code
// Convert Centimetre into Metre in C Program
#include <stdio.h>
int main() {
float c, m, k;
// c = centimeter, m = meter, k = kilometer
printf("Enter the length in centimeter::\n");
scanf("%f", &c);
// It will convert centimeters into metres and kilometers
m = (float)(c / 100);
k = (float)(c / 100000);
// It will print the final output
printf("\nLength in Meter = %f meter \n", m);
printf("Length in Kilometer = %f kilometer\n", k);
return 0;
}
Output
Enter the length in centimeter::
100
Length in Meter = 1.000000 meter
Length in Kilometer = 0.001000 kilometer
Explanation
In this given program, we have taken input 100
length in centimeters, After that we applied the standard formula to calculate length in meters and kilometers.
Then It will return the 1.000000
meter and 0.001000
kilometer output of the program.