A
frequency count is simply the number of times something happens.
An
array frequency count is just a table printing both the element and the number of times it occurs, exactly as in your sample "Response frequency" output.
That's it. If you are feeling underwhelmed by the lack of complexity of this task, don't feel bad.
Lines 30-36 of your code are entirely unnecessary. You don't need to gather any other information.
However, I should point out that this is an
array frequency count, and you are not using an array...
|
int responses[5] = { 0, 0, 0, 0, 0 };
|
This makes your code easy. The user inputs a response == index into the array (but make sure that 0 <= response <= 4) and you need a simple loop to print the resulting table (
n and
responses[n], for
n in 0..4).
Because the results expect you to name the elements of the array, it is helpful to have an additional array with those names:
1 2 3 4 5 6
|
const char* response_names[5] =
{
"Very Bad",
"Bad",
...
};
|
Then when you loop through the array to print the responses you can also print the very useful names:
|
printf("%d-%s %d\n", n, response_names[n], responses[n] );
|
Finally, the
total (
total mark) is nothing more than the sum of the elements of the array. You can gather this by simply adding the inputted response to
total each time.
Don't forget, the
purpose of this assignment is to use arrays and loops together, and to index elements of the array.
Hope this helps.