Question: Write a complete C++ program to read data from a file named Datal.txt (see content of file below) and to calculate and display the

Write a complete C++ program to read data from a file named

Write a complete C++ program to read data from a file named Datal.txt (see content of file below) and to calculate and display the average of each group of numbers in this file. The data is arranged in the file so that each group of numbers is preceded by the number of data items in that group. Therefore the first number in the file, 5, indicates that the next five numbers are in a group. The number 4 indicates that the following four numbers are a group, and the 6 indicates that the last six numbers are a group. (Hint: Use a nested loop. The outer loop should terminate when the end of the file is encontered. Content of file Datal.txt 5 96 87 78 93 21 4 92 82 85 87 6 72 69 85 75 81 73 Your program should produce the following output to the screen given the data in Data 1.txt. CC:\Windows\system32\cmd.exe Numbers read from file: 96 Average 275 Numbers read from file: 92 Average 86.5 Numbers read from file: 72 Average = 75.8333 All done!! 111 87 82 69 78 85 85 93 87 75 21 81 73 X

Step by Step Solution

3.46 Rating (162 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

C program to read data from a file named Data1txt and calculate and display the average of each grou... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!