Write a program to convert km to meter,feet,inch and cm in C

Question:

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

Solution to convert km to m,feet,inch and cm in C

This problem is similar to the previous problem, Calculate gross salary in C. Here, we just have to input the distance between two cities in kilometers. Let’s create a variable named “km” and store the value inputted using scanf() function. Then, using respective variables for meters, feet, inch and centimeters, convert the “km” variable into the respective metric and print the output. I have used the variables ‘m’,’feet’,’inch’ and ‘cm’ for meters, feet, inches and centimeters respectively. Then store the formulas into their respective variables and print the output.

Download the source code:

Download Program

Program to convert km to m,feet,inch and cm in C



Output:

Enter the distance between two cities(in km) – 20
Distance in kilometres = 20.000000
Distance in metres = 20000.000000
Distance in feet = 65616.796875
Distance in inches = 787402.000000
Distance in centimetres = 2000000.000000

Download the source code:

Download Program
Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.

4 comments: