Write a C program to enter length in centimeter and convert it into meter and kilometer.
/*
1m =100cm
1km = 100000cm
*/
Static
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
float centimeter=1000,meter,kilometer;
meter = centimeter/100.0;
kilometer= centimeter/100000.0;
printf("\nLength in meter :- %f",meter);
printf("\nLenght in Kilometer :- %f",kilometer);
getch();
}
Output :-
Dynamic
#include<stdio.h>
#include<conio.h>
void main(){
clrscr();
float centimeter,meter,kilometer;
printf("Enter the value in centimeter:-");
scanf("%f",¢imeter);
meter = centimeter/100.0;
kilometer= centimeter/100000.0;
printf("\nLength in meter :- %f",meter);
printf("\nLenght in Kilometer :- %f",kilometer);
getch();
}
Output :-