Topics Covered1. The main() function
2. Return codes and command-line arguments
3. Fahrenheit-Celsius conversion
Watch Video Part 2a >>
Watch Video Part 2b >>
ExercisesMake the following modifications to fahr.c:
1. The program as written uses integer calculations, limiting its accuracy. Change to use floating-point calculations and output. Print out at least 2 decimal places for all temperatures.
2. Display the output in a two-column table with a heading at the top. Make the decimal points in the output align vertically.
3. Modify the program to accept command-line arguments of the form fahr.exe LOWER UPPER STEP. For example, running the command
fahr 0 150 20.5should produce a table with temperatures going from 0.0 to 150.0 in steps of 20.5. Use the function atof("123.456") to convert a string "123.456" into a floating-point value.
4. Try running the modified program from Step 3 with a variety of possibilities for LOWER, UPPER and STEP. Does it still run correctly if you leave off some of the arguments?
QuestionsWhat is the value of the expression 5/9 after it is assigned to an integer variable? Write a short program to answer this question. Compare your answer with the following alternatives:
100 * (5 / 9)
(100 * 5) / 9
100 * (5.0 / 9.0)
100.0 * (5 / 9)