The distance between two cities(in km) is input through the keyboard. Write a program to convbert and print this distance in meters,feet,inches and centimeters.
#include<stdio.h>
#include<conio.h>
main()
{
float km,m,cm,ft,inch;
printf("\nEnter the distance in kilometers:");
scanf("%f",&km);
m=km*1000;
cm=m*100;
inch=cm/2.54;
ft=inch/12;
printf("\nDistance in meters=%f",m);
printf("\nDistance in centimeter=%f",cm);
printf("\nDistance in feet=%f",ft);
printf("\nDistance in inches=%f",inch);
printf("\n\n\n\nPress any key to exit..");
getch();
}
#include<stdio.h>
#include<conio.h>
main()
{
float km,m,cm,ft,inch;
printf("\nEnter the distance in kilometers:");
scanf("%f",&km);
m=km*1000;
cm=m*100;
inch=cm/2.54;
ft=inch/12;
printf("\nDistance in meters=%f",m);
printf("\nDistance in centimeter=%f",cm);
printf("\nDistance in feet=%f",ft);
printf("\nDistance in inches=%f",inch);
printf("\n\n\n\nPress any key to exit..");
getch();
}
No comments:
Post a Comment