Help with Quiz program

Hi, I really need help with this program. I've been working on it for days and still can't figure it out. The program is supposed to grade a 10 question quiz and output the percent grade. This is what I got so far. The inputAnswers function is working right its the numRight that's giving me problems.
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>

using namespace std;

int A, B, C, D;
const int numQuestions = 10;
void inputAnswers(char given[numQuestions]);
double numRight(char given[numQuestions]);
char given;



int main()
{
    char given[10];
	inputAnswers(given);
	numRight(given);
}


void inputAnswers(char given[])
{
	const int numQuestions = 10;
	for (int a = 1; a <= numQuestions; a++)
	{
		cout << "Please enter your answer for number #" << a << ": ";
		cin >> given[a];
	}
}

double numRight(char given[])
{
	int A, B, C, D;
	double numRight = 0;
    char correctAnswers[10] = {'B', 'C', 'A', 'D', 'B', 'A', 'D', 'C', 'A', 'B'};

		if (given == correctAnswers)
		{
			numRight++;
		}
		
	
	numRight = numRight * 10;

	cout << "Your quiz grade is " << numRight << "%" << endl;
	return 0;
}
Use loop to check the correct answer 1 by 1
I edited it and comment on every change i made.
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>

using namespace std;

int A, B, C, D;
const int numQuestions = 10;
void inputAnswers(char given[numQuestions]);
double numRight(char given[numQuestions]);
char given;



int main()
{
    char given[10];
	inputAnswers(given);
	numRight(given);
}


void inputAnswers(char given[])
{
	const int numQuestions = 10;
	for (int a = 0; a < numQuestions; a++) // "a" must start with 0 as first index of any array is 0 . 
	{
		cout << "Please enter your answer for number #" << a+1 << ": "; // a+1 to print the right num of questions.
		cin >> given[a];
	}
}

double numRight(char given[])
{
	// No need for int A, B, C, D;
	double numRight = 0;
    char correctAnswers[10] = {'B', 'C', 'A', 'D', 'B', 'A', 'D', 'C', 'A', 'B'};
	
	for (int a = 0; a < numQuestions; a++) // You have to check every element of given array with correctAnswers elements.
	{
		if (given[a] == correctAnswers[a])
		{
			numRight++;
		}
	}
	
	numRight = numRight * 10;

	cout << "Your quiz grade is " << numRight << "%" << endl;
	return 0;
}



Please enter your answer for number #1: A
Please enter your answer for number #2: B
Please enter your answer for number #3: A
Please enter your answer for number #4: C
Please enter your answer for number #5: D
Please enter your answer for number #6: A
Please enter your answer for number #7: C
Please enter your answer for number #8: D
Please enter your answer for number #9: A
Please enter your answer for number #10: C
Your quiz grade is 30%
Last edited on
It works!!! Thank you guys so much!!
Topic archived. No new replies allowed.