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
|
#include<iostream>
using namespace std;
int grade(const char master[], const char student[], int);
void main()
{
int howMany;
char answers[] = {'a','b','b','a','c','b','a','a','b','c'};
char student[10];
cout<<"How many questions? ";
cin>>howMany;
cout<<"Enter student answers: ";
cin>>student[0];
grade(answers,student,howMany);
}
int grade(const char master[], const char student[], int howMany)
{
int correct = 0;
for(int i = 0; i<howMany; i++)
{
for(int j = 0; j<howMany; j++)
{
if(master[i] == student[j])
correct++;
}
}
cout<<"You got "<<correct<<" correct"<<endl;
return 0;
}
|