C program to convert kilometer to Centimeter:
Formula: 1 km = 100000 Centimeters
C Proogram to convert kilometers to Centimeter:
#include<stdio.h>
void main()
{
float km, centimeters;
printf("Enter the distance in kilometers = ");
scanf("%f",&km);
centimeteres = km * 100000;
printf("The Kilometers in Centimeters = %f",centimeteres);
}
void main()
{
float km, centimeters;
printf("Enter the distance in kilometers = ");
scanf("%f",&km);
centimeteres = km * 100000;
printf("The Kilometers in Centimeters = %f",centimeteres);
}
Output:
Enter the distance in kilometers = 1
The Kilometers in Centimeters = 100000.000000
The Kilometers in Centimeters = 100000.000000
Explanation:
- Two variables km, meters are declared of type float.
- The value of km is taken from the keyboard given by the user.
- And formula meters = km * 1000000 is applied.
- And last Prints the value of “meters".
See also: C program to convert kilometer to Meter