C Program to Distance Conversion Program

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

  1. #include<stdio.h>
  2.  
  3. main()
  4. {
  5. float km,m,cm,inch,foot;
  6.  
  7. printf("Enter the distance between the two cities in Km: ");
  8. scanf("%f", &km);
  9.  
  10. inch = 39370*km;
  11. foot = 3281*km;
  12.  
  13. cm= 100000*km;
  14. = 1000*km;
  15.  
  16. printf ("\nDistance converted to inches: %f", inch);
  17. printf ("\nDistance converted to feet: %f", foot);
  18.  
  19. printf ("\nDistance converted to centimeters: %f", cm);
  20. printf ("\nDistance converted to meters: %f", m);
  21.  
  22. }


Learn More :