In the program you will have 10 question with A-D answers stores in a array. The answers that the student will give should also be stored in a different array. If the student answers 5 out of th 10 they will pass, and that should be displayed at the end of the program. There should also be a total of the number that correctly and incorrectly answered, with a list of the incorrect questions answered should also be displayed.
I am using the cctype so that the answers will display in uppercase.
I really am not sure about exactly how to put this program together.
Any help I am very thankful for.
Write a program in C++ using arrays.?
here is how you basically use arrays:
Next time try to listen in class instead of panting on the hot guy in front of you, or better have him help you !
int main()
{
const int K_NbQuestions = 10;
// this is the array where you'll place the answers of the student
char studentsAnswers[K_NbQuestions];
// this is where you'll place the expected answers.
char goodAnswers[K_NbQuestions];
// here you do the work of setting the goodAnswers and reading the
//students answers
// now to find the number of correct answers
int nbCorrectAnswers = 0;
for (int questionIdx = 0; questionIdx %26lt; K_NbQuestions; ++questionIdx)
{
if (studentsAnswers[questionIdx] == goodAnswers[questionIdx] )
{
nbCorrectAnswers = nbCorrectAnswers +1;
}
}
// here you print the studient resuts
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment