Knowing that they will have to use 0 in second code to get out of loop just subtract 1 from ding right after the loop.
I believe the problem with your first code is you are asking the user to enter multiple characters "yes" or "no" but you are assigning them to a char with can only store one character. You could change it so they only must enter Y for yes or N for no.
if( average < 60)
{
cout<<"Your average is an F."<<endl;
}
What if the average is a negative number?
sum = sum + math;
can be just sum += math;
while ( math != 0);
What if the user actually got 0 on the test?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
do
{
if ( math < 0 || math > 100 )
{
cout << "Entered scores are invalid. Please try again, or type 0 to stop " << endl;
}
sum = sum + math;
ding++;
cin >> math;
}
while ( math != 0);
Even if the user enters an invalid score, the score is added to sum and ding is incremented.