Please i am new to c++ and i am really finding it difficult understanding this line of code:
++frequency[responses[answer]]
Now a for loop is used to check if answer is lower than the array size of responses which is 40. However array frequency has a size of 11 and all its subscript initialized to 0.
Typing with my phone has prevented me from typing the entire code. But if this does not help i guess am left with no choice.
Are you programming on your phone? I'm sort of doubting it. Next time, please sit down behind your computer so you can provide all the details for your question.
On the single line you posted:
-answer is an int. (e.g. 5)
-responses is an array of ints. (e.g. {2, 4, 6, 1, 3, 7, 9})
-frequence is an array of (probably) ints. (e.g. {1, 3, 5, 7, 9, 11, 13, 15})
For the example numbers provided, the following would happen:
-check value of 'answers' (5)
-get value stored at responses[5] (7)
-increase value of frequency[7]: frequency is now {1, 3, 5, 7, 9, 11, 13, 16}