Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write a C or C++ program Write a program to grade an n -question multiple-choice

ID: 3838905 • Letter: W

Question

write a C or C++ program

Write a program to grade an n -question multiple-choice exam (for n between 5 and 50) and provide feedback about the most frequently missed questions. Your program will take data from the user. The input line contains the number of questions of the exam followed by a space and then an n -character string of the correct answers. Then each input contain an integer student ID followed by a space and then that student's answers. Your program is to produce an output containing the answer key, each student's ID and each student's score as a percentage and then information about how many students missed each question. Here are short sample input and output. Input Number of exam sheets (students): 3 (you can do something else) 5 dbbac 111 dabac 102 dcbdc 251 dbbac Output Exam Report Question: 1 2 3 4 5 Answer: d b b a c Question 1 2 3 4 5 Missed by 0 2 0 1 0 Class Average 80.00

Explanation / Answer

#include<conio.h>
#include<stdio.h>
# define ns 50
struct student{
   int id, score;
   char letter, ans[ns];

};
struct student stud[ns];
void main()
{

int i,j,k,q,ex,qn,correct;
char answer[ns];
float mark;
clrscr();
printf("Enter the no of exasheets ");
scanf("%d",&ex);
printf(" Enter no of questions ");
scanf("%d",&qn);
if( qn >= 5 && qn <= ns)
{   printf("]nEnter answer in series ");
   scanf("%s",&answer);
}
else
{   printf(" ******** There must be 5-50 questions******** ");
   printf("-------PRESS ANY KEY TO EXIT------------");
   getch();
   exit(0);
}
printf(" Student answer time ");
for(i=1; i<= ex; i++)
{
   printf(" Enter student ID then space followed by answer in series ");
   scanf("%d %s", &stud[i].id, &stud[i].ans);
}
// For assigning letter to the student
for(i=0; i<ex; i++)
{
   for(j=0; j<qn; j++)
   {
       if(stud[i].ans[j] == answer[j])
           correct += 1;
   }
   mark =(float)correct/qn * 100;
   if(mark > 90)
       stud[i].letter='A';
   else if(mark >= 80)
       stud[i].letter='B';
       else if(mark >= 70)
           stud[i].letter='C';
           else if(mark >= 60)
               stud[i].letter='D';
               else if(mark < 60)
                   stud[i].letter='F';
}

printf(" Exa Report ");
printf("Questions : ");
for(i = 1; i<= qn; i++)
   printf("%d ",i);
printf(" Answer : ");
for(i = 0; i< qn; i++)
   printf("%c ",answer[i]);

printf(" ID Score(%) Letter");
for(i = 0; i < ex; i++)
   printf(" %d %d %c",stud[i].id, stud[i].score, stud[i].letter);
getch();
}