Hi, i'm supposed to write a function, countGrade that takes in the Grade and find the number of students that have this grade. This value is returned to the calling program. The function prototype is int countGrade(char). Currently all i have written is this.
Seem like there's something wrong with my function but i have no idea how to fix it. Any help would be appreciated. Thanks in advance!
#include <iostream>
#include <string>
using namespace std;
struct markRec {
string id;
string name;
double tt, fe, score;
char grade;
};
struct markRec myMark[] = {
{"B001", "Tan Choon Seng", 34.0, 67.0, 53.8, 'D'},
{"B002", "Anne Smith", 79.0, 88.2, 83.6, 'A' },
{"B003", "Alice Lim", 56.0, 45.0, 49.4, 'F' },
{"N003", "Alan Phang", 67.0, 87.0, 79.0, 'B'},
{"N005", "Ho Tock Seng", 60.0, 67.0, 64.2, 'C'},
{"N0056", "Tan Bee Hoon", 79.0, 88.1, 83.6, 'A'},
};
//The main program
int main (){
char c;
cout << "Enter grade : " ;
cin >> c;
countGrade (c);
return 0;
}
//Function
int countGrade (char c)
{
char grade;
int count;
for ( count = 0; count < grade.size; ++count ) {
if (grade == c )
cout << "The number of students that have grade" << c << "are" << count << endl;
}
return count;
}