Evaluating a Test

A test consisting of 25 multiple-choice items is administered to a batch of 3 students. Correct answers and student responses are tabulated as shown below:
  The algorithm for evaluating the answers of students is as follows:

1.  Read correct answers into an array.
2.  Read the responses of a student and count the correct ones.
3.  Repeat step-2 for each student.
4.  Print the results.

PROGRAM TO EVALUATE A MULTIPLE-CHOICE TEST
Program                                                                    
#define     STUDENTS     3                                 
#define     ITEMS        25                                                                                               
main( )                                                     
{                                                          
   char  key[ITEMS+1],response[ITEMS+1];                  
  int   count, i, student,n,                             
         correct[ITEMS+1];                                 
/*  Reading of Correct answers */                          
   printf("Input key to the items\n");                    
                                                              
        for(i=0; i < ITEMS; i++)                               
      scanf("%c",&key[i]);                                
  
   scanf("%c",&key[i]);                                   
   key[i] = '\0';                                         
                                                              
   /*  Evaluation begins  */                                  
                                                              
      for(student = 1; student <= STUDENTS ; student++)      
      {                                                      
  /*Reading student responses and counting correct ones*/
        count = 0;                                         
        printf("\n");                                      
        printf("Input responses of student-%d\n",student); 
                                                               
        for(i=0; i < ITEMS ; i++)                          
            scanf("%c",&response[i]);                                                                                      
        scanf("%c",&response[i]);                                
        response[i] = '\0';                                
                                                              
        for(i=0; i < ITEMS; i++)                           
            correct[i] = 0;                                  
                                                              
        for(i=0; i < ITEMS ; i++)                          
           if(response[i] == key[i])                       
           {                                                
              count = count +1 ;                           
              correct[i] = 1 ;                             
           }                                               
                                                            
        /* printing of results */                          
                                                              
        printf("\n");                                      
        printf("Student-%d\n", student);                   
        printf("Score is %d out of %d\n",count, ITEMS);    
        printf("Response to the items below are wrong\n"); 
       
              n = 0;                                             
        for(i=0; i < ITEMS ; i++)                          
           if(correct[i] == 0)                             
           {                                               
printf("%d ",i+1);                                     n = n+1;                                    
            }                                                
           if(n == 0)                                         
              printf("NIL\n");                                
           printf("\n");                                      
                                                               
       } /* Go to next student */                             
                                                              
   /* Evaluation and printing ends */                         
   }    
                                                      


 


                                                            
Output                                                   
                                                              
Input key to the items                                      
abcdabcdabcdabcdabcdabcda                                  
                                                              
Input responses of student-1                               
abcdabcdabcdabcdabcdabcda                                   
                                                              
Student-1                                                  
Score is 25 out of 25                                      
Response to the following items are wrong                  
NIL                                                        
                                                              
                                                              
Input responses of student-2                               
abcddcbaabcdabcdddddddddd                                  
                                                              
Student-2                                                  
Score is 14 out of 25                                      
Response to the following items are wrong                  
5 6 7 8 17 18 19 21 22 23 25                               
                                                              
Input responses of student-3                               
aaaaaaaaaaaaaaaaaaaaaaaaa                                  
                                                           
Student-3                                                  
Score is 7 out of 25                                       
Response to the following items are wrong                 
2 3 4 6 7 8 10 11 12 14 15 16 18 19 20 22 23 24             

No comments:

Post a Comment

Copyright © EduRAR @ www.edurar.blogspot.in