Write a C program to calculate the distance between two cities

c program afor distance conversion
c program afor distance conversion

Problem Statement:

The distance between two cities (in km.) is input through the keyboard. Write a C program to convert and print this distance in meters, feet, inches and centimeters.

Answer:

/* Conversion of distance */

#include <stdio.h>
#include <conio.h>

main()
{

float km, m, cm, ft, inch;

clrscr(); /* To clear the screen */
print(“\n Enter the distance in Milometers:”);
scanf(“%f”, &km);

m=km*100;
cm=m*100;
inch=cm/2.54;
ft=inch/12;

printf(“\nDistance in mters=%f”,m);
printf(“\nDistance in centimter=%f”,cm);
printf(“\nDistance in feet=%f”,ft);
printf(“\nDistance in inches=%f”,inch);

printf(“\n\n\n\n\n Press an key to exit….”);
getch(); /* To read a character from keyboard */
}

Please run this program and share the output with us.

 

Satya Prakash

VOIP Expert: More than 8 years of experience in Asterisk Development and Call Center operation Management. Unique Combination of Skill Set as IT, Analytics and operation management.

Leave a Reply