Friday, August 29, 2014

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 centimeters


Code

Hint: 1 km = 1000 meters, 1 meter = 3.28 feet, 1 foot = 12 inches, foot = 30 centimeters

#include<stdio.h>
int main()
{
int a,b,c,d,f;

printf ("Enter the distance (in km): ");
scanf ("%d",&a);

b = a * 1000;
c = b * 3.28;
d = c * 12;
f = d * 30;

printf ("\nDistance in meters = %d m",b);
printf ("\nDistance in feets = %d feet",c);
printf ("\nDistance in inches = %d inches",d);
printf ("\nDistance in centimeters= %d cm",f);

printf ("\n\npress any key to close.");

getch ();
return 0;
}

Output

distance conversion C Language

3 comments :

Note: Only a member of this blog may post a comment.

Copyright 2017. All Rights Reserved. Privacy Policy / Terms And Conditions / Sitemap / Contact