Question: Programming Exercises Using a file named input.txt , write C++ code statements to do the following: Create a stream variable for accessing the file and
Programming Exercises
- Using a file named input.txt, write C++ code statements to do the following:
- Create a stream variable for accessing the file and any other necessary variables.
- Open the file, read the integer values from the file, calculate the average of the values in the file, and display the average to the screen.
- If you are unable to open the file, display an error message.
- Close the file when you have finished reading.
*Note: You do not need to write main or any functions.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
