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...
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>
usingnamespace std;
int main()
{
constint 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
-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?