0
# include <iostream>
using namespace std;

void displayGrade (int ) ;
int main()
{
    const int SENTINEL = -1;
    int score;
    int sum;
    int count;
    int average;
    
    count = 0 ;
    sum = 0 ;
    cout << " Enter scores one at a time as requested . " << endl;
    cout << " When done, enter " << SENTINEL << " to stop. " << endl;
    cout << " Enter the first score : " ;
    cin >> score;
    while (score != SENTINEL )
    {
          sum += score;
          count++;
          displayGrade(score);
          cout << endl << "Enter the next score : " ;
          cin >> score;
          } 
          
          cout << endl<< endl;
          cout << " Number of score processed is " << count << endl ; 
    cout << " Sum of exam scores is" << sum << endl;
    
    if (count > 0 ) 
    {
              average =sum / count ;
              cout << " Average score is << average" << endl ;
              }
              system ("pause" );
              return 0 ;
              }




// get the data
void displayGrade ( int score)

{
    if ( score >= 90 ) cout << "grade is A" << endl;
    else if ( score >=80 ) cout << "grade is B " << endl;
    else if ( score >= 70 ) cout << " grade is C " << endl;
    else if ( score >= 60 ) cout << " grade is D " << endl;
    else cout << "grade is F " << endl;
}
return displayGrade;

the problem is " expected unqualified ID ... return "" .... .
I don't know why, please help me
while (score != SENTINEL )
{
sum += score;
count++;
displayGrade(score);
cout << endl << "Enter the next score : " ;
cin >> score;
}
and I am not clear about this repetition, can you explain it to me in a simple way
thank you

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Denniz
0

Take away this line:

return displayGrade;

As for the loop, it will keep on prompting you for the next score, until you enter -1 then it will come out of the loop.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.