Array Help For Grades

Generate a text-based histogram for a quiz given to a class of students. The quiz is graded on a scale from 0 to 5. Write a program that allows the user to enter grades for each student. As the grades are being entered, the program should count, using an array, the number of 0’s, the number of 1’s, then number of 2’s, the number of 3’s, the number of 4’s and the number of 5’s. The program should be capable of handling an arbitrary number of student grades.

You can do this by making an array of size 6, where each array element is initialized to zero. Whenever a zero is entered, increment array[0]. Whenever a one is entered, increment array[1], and so on, up to array[5].

Output the histogram count at the end. For example, if the input grades are 3, 0, 1, 3, 3, 5, 5, 4, 5, 4, then the program should output

1 grade(s) of 0
1 grade(s) of 1
0 grade(s) of 2
3 grade(s) of 3
2 grade(s) of 4
3 grade(s) of 5

I have no idea how to finish up this program. I have started it, but I do not know what else to put in it. I'm a noob when it comes to coding :/. Examples and what not are appreciated, Here's what I have so far:

using namespace std;

int main ()
{
int i;
string grades[6];
int zero,one,two,three,four,five;

for (i=0; i<6; i++)
{
cout<< "Enter students grades";
getline (cin, grades [i]);
}



cout <<"0 grades"<<zero[i]<<endl;
cout<<"1 grades"<<one[i]<<endl;
cout<<"2 grades"<<two[i]<<endl;
cout<<"3 grades"<<three[i]<<endl;
cout<<"4 grades"<<four[i]<<endl;
cout<<"5 grades"<<five[i]<<endl;

system ("pause");


return 0;

}
Topic archived. No new replies allowed.