Firstly, Use meaningful variable names, A lot of problems are solved by an easy to read code.
IE your variables make more sense like:
vector<Record> StudentScores
int NumberOfStudents
Record StudentGrades
I believe You've declared your struct wrong.
You declared a struct with only float in it, which is pointless to have a struct containing one variable.
Then followed creating a vector of that struct, which is the same as just creating a vector of floats. Since your struct only contains float.
Basically useless when you could just do a vector of whatever type you wanted rather. Unless the teacher wants a struct containing one variable.
You're also calling your function incorrectly.
You are redeclaring it rather than calling it in main
1 2 3 4
|
float ave(vector<Record> &a);
// should be
ave(a);
//This might be why you arent printing what you want to. I imagine its not returning anything significant.
|
(also you cant cout ave since its not declared properly, it should be cout << (ave(a)) if you wanted to cout average in main.)
Followed by your function not initializing sum. How can you add to sum if you dont know its value?
I would begin by fixing these issues then taking a second look. Writing an algorithm before you begin will benefit you.
Sorry for all the edits, Just kept trying to give more help lol