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.

 

Related Posts

  • 42
    Problem Statement: The length & breadth of a rectangle and radius of a circle are input through the keyboard. Write a program to calculate the area & perimeter of the rectangle, and the area & circumference of the circle. Answer: /* Calculation of perimeter and area of rectangle and circle…
    Tags: printf, program, calculate, write
  • 37
    Problem Statement: Write a program to calculate the salary as per the following table: Solution: /* C program to calculate salary */ main( ) { char g ; int yos, qual, sal ; printf ( "Enter Gender, Years of Service and Qualifications ( 0 = G, 1 = PG ):" )…
    Tags: program, calculate, write
  • 35
    Write a C Program for the following :- Ramesh’s basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. Write a program to calculate his gross salary. Answer:  /* To Calculate the gross salary of Ramesh…
    Tags: printf, program, write, calculate, keyboard, #include
  • 33
    Problem Statement: Temperature of a city in Fahrenheit degrees is input through the keyboard. Write a c program to convert this temperature into Centigrade degrees. Answer: /* Conversion of Temperature from Fahrenheit to Centigrade */ #include <stdio.h> #include <conio.h> main() { float fr, cent; clrscr(); print("\n Enter the temperature in…
    Tags: program, printf, #include, conversion, write, keyboard, print
  • 31
    Let's have an example to understand else if clause : /* else if ladder demo */ main( ) { int m1, m2, m3, m4, m5, per ; per = ( m1+ m2 + m3 + m4+ m5 ) / per ; if ( per >= 60 ) printf ( "First…
    Tags: printf, program, write

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

Your email address will not be published. Required fields are marked *

%d bloggers like this: