The input for this program should be like this:
How many tests? 4
Grade on Test 1? 95
Grade on Test 2? 88
Grade on Test 3? 80
Grade on Test 4? 96
Your average is: 89.75 <------- this is where I can't get it right, can anybody take a look at my code and tell me how to get all those scores for average? Thanks.
Here is my code:
int main()
{
int totnum[20] ;
int c = 1 , x ;
cout << "How many tests? " ;
cin >> x ;
while (c <= x)
{
cout << "Grade on Test " << c << "? " ;
cin >> totnum[c]; c = c + 1;
}
double avg = totnum[20]/x;
cout << "Your average is " << avg << endl ;
}