Checking mult choice test answers!

I can't get seem to get the syntax right non this. I am trying to check a correct answer array against an array of answers filled into the program by the user. After that I want to display the total number of correctly and incorrectly answered questions, and a list showing the question numbers of the incorrectly answered questions. THANK YOU!!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const int SIZE = 20;
char instructor[SIZE] = {'B','D','A','A','C','A','B','A','C','D','B','C','D','A','D','C','C','B','D','A'};
char student[SIZE];
ifstream answer;
int letter_ans, total;


	for(int n = 0; n < SIZE; n++)

		{
		
			cout << "Enter answer number " << n << ". " << endl;
					
			cin >> student;
				
			if (student == 65 || student == 66 || student == 67 || student == 68)
					
				cout << "Please enter an uppercase A, B, C or D. " << endl;

				else

			
					for( int i = 0; instuctor[i] && student[i]; i++ )
    
        if( instructor[i] = student[i] )
    
			 while (i < SIZE && InputFile >> instructor[i])
				total+= student[i]
				 count++;
Last edited on
Your for loop on line 23 is incorrect I believe. It's in your condition:

for( int i = 0; instuctor[i] && student[i]; i++ )
How is this loop ever going to work with the instructor[i] && student[i]? What is it supposed to be doing?

You need a condition to stop this loop! for instance
1
2
3
4
5
6
7

const int SIZE = 20; 

.... //Body here
for (int c = 0; c <= SIZE; c++)
   if (instructor [c] == student [c])    //Look at my equal signs!!!
      //Do something 


On your line 25, you are trying to ASSIGN the student answers TO the instructor answer.
Make sure that you put a double equal sign; ' == '

these should fix your problems.
Last edited on
Topic archived. No new replies allowed.