Need help.
Grade wont output.
*I only placed grade for A for now to test* but then it wont show.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#include <iostream>
using namespace std;
struct sData
{
string fName;
string lName;
int tScore;
char sGrade;
};
void findGrade (sData);
sData highest (int tScore);
int main()
{
sData student[20];
for (int x = 0;x<20;x++){
cout<<"Enter Student's First name: ";
cin>>student[x].fName;
cout<<"Enter Student's Last name: ";
cin>>student[x].lName;
cout<<"Enter Student's test score: ";
cin>>student[x].tScore;
cout<<"Grade: "<<student[x].sGrade<<endl;
}
return 0;
}
//Student's grade.
void findGrade (sData student[])
{
for (int k=0;k<20;k++)
{
if (student[k].tScore > 91){
student[k].sGrade = 'A';
}
}
}
|
findGrade is never called. sGrade has not been assigned a value when you try to print it one line 23.
Topic archived. No new replies allowed.