How to write a C Program to Distance Conversion Program in C Programming Language ?
Solution:
This Program converts the value entered in Km to inches, centimetres, feet and metres.
The distance between two cities (in km.) is input through the keyboard.
Write a program to convert and print this distance in meters, feet, inches and centimetres.
/*
Distance Conversion:
1Km = 39370 inches
1Km = 3281 Feet
1Km = 100000 Cm
1Km = 1000 metres
*/
Distance Conversion:
1Km = 39370 inches
1Km = 3281 Feet
1Km = 100000 Cm
1Km = 1000 metres
*/
- #include<stdio.h>
- main()
- {
- float km,m,cm,inch,foot;
- printf("Enter the distance between the two cities in Km: ");
- scanf("%f", &km);
- inch = 39370*km;
- foot = 3281*km;
- cm= 100000*km;
- m = 1000*km;
- printf ("\nDistance converted to inches: %f", inch);
- printf ("\nDistance converted to feet: %f", foot);
- printf ("\nDistance converted to centimeters: %f", cm);
- printf ("\nDistance converted to meters: %f", m);
- }