Lab 6 - Basic File I/O

In this lab, you will be learning how to use input and output files.

You will be writing a program that reads a list of integers from a file, calculates the sum and average of those integers, and then outputs the sum and average to a second file.

Copy the following data file to your directory for input: lab6_input.txt

Use the loop shown in lecture on Wednesday to read from the file. You will need additional variables to keep track of the sum and of the number of integers in the file (refer back to Lab 3 for how to calculate the sum).

After you exit the input loop, your sum variable should have the overall sum and your counter variable should contain the number of integers in the file. That will give you the required information to compute the average. Make sure to use double division to compute the average.

Output the sum and average to a file called "lab6_output.txt". Don't forget to close both files.

Name your source code lab6.cpp. Email me the completed source code.