Answer:
The program in C++ is as follows:
#include <iostream>
using namespace std;
char input(){
char student; cin>>student;
return student;
}
int compare(char student, char teacher){
int score = 0;
if(tolower(student) == tolower(teacher)){ score++;
}
return score;
}
int main(){
char teacher[5] = {'C', 'D', 'B', 'B', 'A'};
int score = 0;
for (int i = 0;i<5;i++){
cout<<"Question "<<i+1<<": ";
char student = input();
score+= compare(student,teacher[i]);
}
cout<<"You answered "<<score<<" out of 5 questions correctly";
return 0;
}
Explanation:
Given
See attachment (1) for complete question
See attachment (2) for complete source file where comment are used to explain