logo CodeStepByStep logo

Weather

Language/Type: C file input
Related Links:

Write a console program that reads an input file of temperatures, with real numbers representing daily high temperatures such as:

16.2
23.2
19.2
7.7
22.9
18.4
-1.6
14.6

Your program should prompt for the file name to read, then read its data and print the change in temperature between each pair of neighboring days.

Input file? weather.txt 
16.2 to 23.2, change = 7.0
23.2 to 19.2, change = -4.0
19.2 to 7.7, change = -11.5
7.7 to 22.9, change = 15.2
22.9 to 18.4, change = -4.5
18.4 to -1.6, change = -20.0
-1.6 to 14.6, change = 16.2

You may assume that the user types the name of a file that exists and is readable, and that the file will contain at least two temperatures in it.

Function: Write a C function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.