Exercise 2:
The distance between two cities (in Km) is input through the keyboard. Write a program to convert and print the distance in meters, feet, inches and centimeter.
Solution:
The output of the program is as follows:
Please enter distance between two cities in Kilometer = 10
Therefore 10.0000 Km = 10000.0000 m = 32808.3980 feet = 393700.7870 inch = 1000000.0000 cm
The distance between two cities (in Km) is input through the keyboard. Write a program to convert and print the distance in meters, feet, inches and centimeter.
Solution:
#include<stdio.h>In this program the, the distance in Kilometers is taken from the user, and then the corresponding calculation for conversion is done and then the corresponding values are displayed to the user.
#include<conio.h>
void main()
{
float dkm, dm, dft, din, dcm;
printf(“Please enter distance between two cities in Kilometer = ”);
scanf(“%f”, &dkm);
dm=dkm*1000;
dcm=dm*100;
dft=3280.8398*dkm;
din=39370.0787*dkm;
printf(“\nTherefore %f Km = %f m = %f feet = %f inch = %f cm”, dkm, dm, dft, din, dcm);
getch();
}
The output of the program is as follows:
Please enter distance between two cities in Kilometer = 10
Therefore 10.0000 Km = 10000.0000 m = 32808.3980 feet = 393700.7870 inch = 1000000.0000 cm
No comments:
Post a Comment
Please give your valuable comments or queries if you fell its helpful or if you like the contents of the site. Thanks...