I have been given a text file that contains 365 lines, 1 number on each line. Each number is the amount of steps someone took per day for a whole year. The task is to calculate the average number of steps per month, using the daily amount of steps. I am completely stumped. I have no idea how I would take chunks of information from the file (lines 1-31 for january, lines 32-62 for february, and so on). The for loop is still a little confusing to me. Someone else that created this program said they used a while loop with a nested for loop, but I cannot picture how that would work out. This is literally all I have so far.
This program displays the average number of steps taken per month,
based on information from a text file. */
#include <iostream>
#include <iomanip>
#include <fstream>
usingnamespace std;
int main()
{
ifstream inputFile;
// Amount of days for each month
/* Jan, Mar, May, July, Aug, Oct, Dec = 31 days
Apr, June, Sept, Nov = 30 days
Feb = 28 days */
int avg, days, value;
// Open the file
inputFile.open("steps.txt");
return 0;
}