3.2 Write a C program that converts a distance, in feet, ormiles, to a distance
ID: 3610050 • Letter: 3
Question
3.2 Write a C program that converts a distance, in feet, ormiles, to a distance in meters or kilometers, or frommeters/kilometers to feet/miles. This should be a single program.The user will specify the units of the input value using anadditional character after the number indicating the unit type,i.e., “23.7 m” for meters, “45.62 f”, forfeet, “5.2 M” for miles, and “2.34 K” forkilometers. The conversion is then based on the units of the input.The input number must be a floating point (i.e., a real number),and the output should bea floating point number with only 3digits after the decimal point printed out.
Explanation / Answer
Sounds to me like your problem is with the printing (since that'swhat was bold). I'm not about to write the whole program for you,but lets suppose you have some floating point number double num; and somewhere in your program you assign num thevalue based on the user input, etc. To print ndigits of the floating point number, use this syntax: printf ("%.3f", num); Good luck!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.