#include <iostream>
usingnamespace std;
//function to sets each array element to the correct answer according to the table
void setCorrectAnswers (int corrrectAnswers[10])
{
corrrectAnswers[0]=5;
corrrectAnswers[1]=22;
corrrectAnswers[2]=35;
corrrectAnswers[3]=0;
corrrectAnswers[4]=16;
corrrectAnswers[5]=28;
corrrectAnswers[6]=4;
corrrectAnswers[7]=3;
corrrectAnswers[8]=42;
corrrectAnswers[9]=51;
}
//function to asks the student to input their answers to each of the 10 questions
void inputAnswers(int givenAnswers[10])
{
for(int i=0; i<10; i++)
{
cout<<"please enter your answer for question #"<<(i+1)<<" ";
cin>>givenAnswers[i];
}
}
//function to it sets numright to the number of questions the student answered correctly.
int numberCorrect(int corrrectAnswers[10],int givenAnswers[10])
{
int numRight=0;
for(int i=0; i<10; i++)
{
if(corrrectAnswers[i]==givenAnswers[i])
numRight++;
}
return numRight;
}
int main()
{
//declaration
int corrrectAnswers[10];
int givenAnswers[10];
int numRight;
//calling functions
setCorrectAnswers(corrrectAnswers);
inputAnswers(givenAnswers);
//calculate number of right answers
numRight= numberCorrect(corrrectAnswers,givenAnswers);
//print grade
cout<<"Your quiz grade is "<<((float)(numRight/10.0f)*100.0f)<<"%"<<endl;
return 0;
}