HOW TO FIND THE AVERAGE OF NUMBERS FROM EXCEL

Im trying to take numbers from excel and find the average of each row .
I have this program but I don't know how to find the average.

cpp.sh/2wjft
What is the format of the input file? A sample would be useful.

Also, you are more likely to get a response if you post your code here rather than just a link.


You may as well use the C++ string and stringstream classes, it simplifies the task. The exact details will vary depending on the file format. If each line contains just a list of numbers, this could work, or at least be a step towards a solution.
1
2
#include <string>
#include <sstream> 

1
2
3
4
5
6
7
8
9
10
11
12
    string line;
    
    while (getline(file_in, line))
    {
        istringstream ss(line);
        int total = 0;
        int n;
        while (ss >> n)
            total += n;
            
        cout << "Grades: " << line << "  Total: " << total << endl;
    }
Last edited on
Topic archived. No new replies allowed.