void inputAnswers(char givenAnswers[]){
int i;
for (i = 0; i<10; i++){
cout << "Please enter your answer for question #" << (i + 1) << ": ";
cin >> givenAnswers[i];
}
}
int numCorrect(char correctAnswers[], char givenAnswers[]){
int numRight = 0;
int i;
for (i = 0; i<10; i++){
if (correctAnswers[i] == givenAnswers[i]){
numRight++;
}
}
return numRight;
}
This is the output--Quiz grade is 0%
even after entering correct answers
Does absolutely nothing.
It's the same as doing...
1 2 3 4 5
void f()
{
42; // I'm just a number, or in your case, a character.
// I'm not doing anything!
}
Do you see why that isn't doing anything? It isn't assigning anything, there's no =, nothing is being set.
For an array, you have to set each element individually except if you're initializing an array (which you aren't if you're passing an already-existing array into a function).
1 2 3 4 5 6 7
void setCorrectAnswers(char correctAnswers[])
{
correctAnswers[0] = 'B';
correctAnswers[1] = 'C';
// ... fill the rest in 2-8
correctAnswers[9] = 'B';
}
Hey thanks for the advice. I was confused on how to actually have the main call the char correctAnswers procedure. True it would be, but this program has to have three functions and not two. I'll post the new void setCorrectAnswers and see if anything happens.