help with simulating drivers license test

im doing a project where i have to simulate a drivers license test using arrays and im SOOO confused about arrays. i've looked all over online and nothing i find helps with the way i need to do it.

-10 questions
-answers consist of A, B, C, D
-correct answers are stored in an array named "correctanswers"
-initialize this array with correct answers B C B A D C C A B D
-user is asked to enter his answers and they are accepted into an array named "studentanswers"
-write a function named "testresult"with two array parameters which compares the corresponding elements of these two arrays and returns an integer which is the number of matching elements.
-call this function in the main part of the project with appropriate arguments
-display the number of correct answers and the full list of correct answers

here's what the final screen needs to look like.

Enter your answers (A B C or D) to ten questions:
A C B B D C C B A D
you have answered 6 correctly!
The correct answer is:
B C B A D C C A B D
Press any key to continue...

thanks... this is driving me crazy
Last edited on
Here you are, @murry4 - have a go and more people will respond to your post.

-10 questions
-answers consist of A, B, C, D
-correct answers are stored in an array named "correctanswers"
1
2
3
4
5
6
7
8
#include <iostream>
using namespace std;

int main()
{
   const int NUMQ = 10;           // number of questions
   char correctanswers[NUMQ];     // an array correctanswers to contain just that!
}


There you are: 3 parts done already!

Now, how are you going to:
-initialize this array with correct answers B C B A D C C A B D

Clue1 - look at http://www.cplusplus.com/doc/tutorial/arrays/ and, particularly, initialisation
Clue2 - put individual characters in as 'B', 'C', ...

And what about:
-user is asked to enter his answers and they are accepted into an array named "studentanswers"

Clue1 - another array of the same size and type!
Clue2 - "student is asked to ..." - how do you write to the console?
Clue3 - "... enter his answers" - how do you read from the keyboard?


5 parts done! Only 3 to go!


Then:
write a function named "testresult ...

Clue1 - see http://www.cplusplus.com/doc/tutorial/functions/


Have a go!


Last edited on
Topic archived. No new replies allowed.