logo CodeStepByStep logo

gas_prices

Language/Type: C file input
Related Links:
Author: Allison Obourn (on 2020/09/14)

Write a program that reads a file gasprices.txt. The file is formatted as follows:Belgium $/gal US $/gal date. Example file:

8.20    3.81    3/21/11
8.08    3.84    3/28/11
8.38    3.92    4/4/11
8.62    4.03    4/11/11

The program should print the average gas price over all data in the file for both countries. For example, with the file contents above, your program should output:

Belgium average = 8.3
USA average = 3.9
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.