Wondering if someone could guide me in the right direction. I think this code is right but can't figure out why my switch loop won't access my char array of grades and add it to an int array.
#include <stdio.h>
int main (void)
{
char grade[32] = {
'A', 'B', 'C', 'D', 'f', 'I',
'b', 'C', 'd', 'F', 'I', 'a',
'C', 'D', 'F', 'I', 'A', 'B',
'D', 'F', 'I', 'A', 'B', 'c',
'I', 'D', 'F', 'F', 'A', 'B',
'a', 'b'};
char letters[6] = { 'A', 'B', 'C', 'D', 'F', 'I'};
int i, hist_grade[6];
for (i = 0; i < 32; ++i)
grade[i] = 0;
{
switch(grade[32])
{
case'A':
case'a':
++hist_grade[i];
break;
case 'B':
case 'b':
++hist_grade[i];
break;
case 'C':
case 'c':
++hist_grade[i];
break;
case'D':
case'd':
++hist_grade[i];
break;
case'F':
case'f':
++hist_grade[i];
break;
case 'I':
case 'i':
++hist_grade[i];
break;
}
}
printf ("\n\nGrade Number of Each Grade\n");
printf ("----- --------------------\n");
for (i = 0; i < 6; ++i)
printf ("%c%8i\n", letters[i] , hist_grade[i]);
getchar();
return 0;
}