## Friday, June 23, 2006

### Distance Conversion Program

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
*/

#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);

}

#### 1 comment:

jamal said...

hi can u write a code that looks up the driving distance between two cities. Use two drop-down boxes that contain the names of the cities. Label one drop-down Departure and the other Destination. Use a Distance button to find and display the distance, and a Clear button to clear the selection.

Distance Table
Boston Chicago Dallas Las
Vegas Los
Angeles Miami New
Orleans Toronto Vancouver Washington
DC
Boston 0 1004 1753 2752 3017 1520 1507 609 3155 448
Chicago 1004 0 921 1780 2048 1397 919 515 2176 709
Dallas 1753 921 0 1230 1399 1343 517 1435 2234 1307
Las Vegas 2752 1780 1230 0 272 2570 1732 2251 1322 2420
Los Angeles 3017 2048 1399 272 0 2716 1858 2523 1278 2646
Miami 1520 1397 1343 2570 2716 0 860 1494 3447 1057
New Orleans 1507 919 517 1732 1858 860 0 1307 2734 1099
Toronto 609 515 1435 2251 2523 1494 1307 0 2820 571
Vancouver 3155 2176 2234 1322 1278 3447 2734 2820 0 2887
Washington DC 448 709 1307 2420 2646 1057 1099 571 2887 0