Introduction:
In this post I discuss about converting distance from kilometer to other units by C programing language. Here user input distance in kilometer then that convert into meters, feet, inches, and centimeters by C program and display the output.
What is Distance :
Distance is a measure of the length. How long a thing or how far a object is situated, we measure by distance. There are different type of units we found, like kilometers, meters, centimeters, miles, yards, feet, and inches. In everyday life we need to convert distance between units.
Formula to calculate the distance into different units :
Meter = kilometer X 1000
Feet = kilometer X 3280.84
Inches = kilometer X 39370.1
Centimeter = kilometer X 100000
How run the program :
For run this program you have install VS Code in your pc then create a C file in VS Code. Now copy the below code and paste in C file you have create and save. Then run the program.
#include <stdio.h>
int main() {
float kilometer,meter,feet,inch,centimeter;
printf("Enter Length in Kilometer : ");
scanf("%f", & kilometer);
meter = kilometer * 1000;
feet = kilometer * 3280.84;
inch = kilometer * 39370.1;
centimeter = kilometer * 100000;
printf("%f Kilometer = %f Meters\n", kilometer, meter);
printf("%f Kilometer = %f Feets\n", kilometer, feet);
printf("%f Kilometer = %f Inches\n", kilometer, inch);
printf("%f Kilometer = %f Centimeters\n", kilometer, centimeter);
return 0;
}
Output :
After that you see the following output in your pc.
Conclusion :
I think you would be understand how convert distance in various units. Thank you for visit my site.
You can see my other project :
- How to Draw Moving Bicycle by C Graphics with Source Code
- how to create lighting with sound by c graphics with source code
- How to Draw Coloring Circle One by One By C With Source Code
- How to Create Animated Face by C or C++ Graphics Program with Source Code