# I need help comparing arrays

• 11-09-2012
Guy_from_SoCal
I need help comparing arrays
Why isn't my code running.

Here's the description of the problem. My code is below it.

The local Driver's License Office has asked you to write aprogram that grades the written portion of driver's license exam.The exam has 20 multiple choice questions. Here are the correctanswers:
1. B 6.A 11.B 16. C
2. D 7.B 12.C 17. C
3. A 8.A 13.D 18. B
4. A 9.C 14.A 19. D
5. C 10.D 15.D 20. A
Your program should store the correct answers shown above inan array. It should ask the user to enter the student's answers foreach of the 20 questions, and the answers should be stored inanother array. After the student's answers have been entered, theprogram should display a message indicating whether the studentpassed or failed the exam. (A student must correctly answer 15 ofthe 20 questions to pass the exam.)
It should then display the total number of correctly answered questions, the total number of incorrectly answered questions, and a list showing the questions numbers of the incorrectly answered questions.
Input Validations: Only accept the letters A, B, C, or D as answers.

Code:

Code:

#include <iostream>using namespace std;

int main()
{
char right_answers[number_of_answers] = {'B', 'D', 'A', 'A', 'C', 'A', 'B', 'A', 'C', 'D',

'B', 'C', 'D', 'A', 'D', 'C', 'C', 'B', 'D', 'A'};

return 0;
}

{
for (int counter=0; counter < number_of_answers; counter++)
{
cout << "Enter your answer for question " << (counter + 1) << endl;

{
cout << "ERROR: Only A,B,C, and D are valid.\n";
cout << "Question " << (counter + 1) << ": ";
}
}

}

{
for(int x=0; x <= number_of_answers; x++)
{
{
}

}
}

{

for (int x=0; x< number_of_answers; x++)
{
{
for (x = 0; x<number_of_answers; x++)
{
cout << "Answer " << (x+1)<< " is incorrect" << endl;
}
}
}
}

cout << "Results (minimum 15 correct to pass): " << endl;
cout << "You got " << answered_correctly << " correct." << endl;
cout << "You missed " << missed << endl;
{
cout<< "You've passed!" << endl;
}
else
{
cout << "You'ved failed." << endl;
}
}

• 11-09-2012
Salem
Do you know the difference between pass by value and pass by reference?

How is calculate_grade() going to pass an updated answered_correctly back to main?

> for(int x=0; x <= number_of_answers; x++)