Write a program that grades arithmetic quizzes as follows: Ask the user how many
ID: 652637 • Letter: W
Question
Write a program that grades arithmetic quizzes as follows:
Ask the user how many questions are in the quiz.
Ask the user to enter the key (that is, the correct answers). There should be one answer for each question in the quiz, and each answer should be an integer. They can be entered on a single line, e.g., 34 7 13 100 81 3 9 10 321 12 might be the key for a 10-question quiz. You will need to store the key in an array.
Ask the user to enter the answers for the quiz to be graded. As for the key, these can be entered on a single line. Again there needs to be one for each question. Note that these answers do not need to be stored; each answer can simply be compared to the key as it is entered.
When the user has entered all of the answers to be graded, print the number correct and the percent correct.
When this works, add a loop so that the user can grade any number of quizzes with a single key. After the results have been printed for each quiz, ask
Explanation / Answer
#include<stdio.h>
#include<conio.h>
void main()
{
int key[10],a[10],i,c=0;
char ans='y';
while (ans=='y')
{
clrscr();
c=0;
printf(" Enter 10 keys for Quiz");
for(i=0;i<10;i++)
{
scanf("%d",&key[i]);
}
printf(" Enter 10 answers for Quiz");
for(i=0;i<10;i++)
{
scanf("%d",&a[i]);
}
printf(" Following answers are correct for Quiz");
for(i=0;i<10;i++)
{
if(key[i] == a[i])
{
printf(" %d",a[i]);
c++;
}
}
printf(" Total correct answers are %d", c);
printf(" Grade another Quiz?(y/n) ");
ans=getch();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.