# Accumulator Troubles: NEWBIE

• 12-08-2003
sevenhallz
Accumulator Troubles: NEWBIE
NEWBIE TO C++

Desperately need help figuring out how to accumulate total number of grades(A, B, C Etc..) in a student test program.
I'm using an array called int avg[20] Any ideas on how to get this thing going would be great! Here's were I am... I'm not sure if I'm on the right track.
Code:

```void totalGrades(string stuName[], int t1[], int t2[], int t3[], int avg[], short size) {         int x        = 0;            int minScore = avg[0];            int maxScore = avg[20];                int count    = 0;                  int nsub = 0;         char grade = ' ';                 x = 0;                 while (x < 20)                 {                         if (avg[x] >= 90)                                 avg[x] = 'A';                                 count = count + 1;                         if (avg[x] = >= 80)                                 avg[x] = 'B';                                                         x = x + 1;                                                                                                 } //end while                 cout << "Total Grades: "<< count << endl;         }```
Thanks,
Seven
• 12-08-2003
-=SoKrA=-
In the line:
Code:

`if (avg[x] = >= 80)`
the first = will give you trouble, change that line to
Code:

`if (avg[x] >= 80)`
• 12-08-2003
Oluf
you would need a { and } for your "if"īs so it would be

Code:

```if (avg[x] >= 90)  {   avg[x] = 'A';   count = count + 1; }```
• 12-08-2003
CornedBee
You could also convert all grades to 1-5, it would make stuff easier. That's the Austrian way btw.
• 12-08-2003
WDT
You may want your program to exit when after the suitable case is met instead of going through all of them each time in the loop, so try using switch/case statement or nested if/elses' (recommend the former). Also do what the previous two guys advise, especially oluf, if you want to execute multiple statements after a case is met.