I've only been coding for about a month, so bare with me. In my programming class the assignment is to write a program, using arrays and functions, to:
-have the user input their test answers
-compare that to the given test answers
-calculate the score
The only error that is coming up is: "expression must have pointer-to-object type"/"subscript requires array or pointer type".
The arrays I did for the previous project looked the exact same and they were fine. The instructions call for functions to return the array values. Any help would be appreciated.
Well, fist your actual functions doesn't match the prototypes... inputAnswers() should return void and take an array of ints, and numberCorrect() should take only one int, according to your function prototypes.
Second, inputAnswer()'s prototype is correct, but for numberCorrect() it's supposed to be int numberCorrect(int givenAnswers[], int correctAnswers[]);. Notice that we have to pass in arrays in order for your code to work.
Last, if you want numberCorrect() to take two int[]s and return the number of right answers (which I suggest you to do), you have to add int numRight = 0; before your for loop in numberCorrect(). And when you call it, you call it like this: numRight = numberCorrect(givenAnswers, correctAnswers);.