Question

In: Computer Science

Write a program in C to grade an n-question multiple-choice exam (for n between 5 and...

Write a program in C to grade an n-question multiple-choice exam (for n between 5 and 20) and provide feedback about the most frequently missed questions. Your program will use a function scan_exam_data to scan and store the exam data in an appropriate data structurer. Use file redirection to input data – do not use fopen() in your code. The first line of input contains the number of students. Second line is number of questions on the exam followed by a space and then an n-character string of the correct answers. Each of the lines that follow contain an integer student ID followed by a space and then the student answers.


Sample Input

3

5 dbbac

111 dabac

102 dcbdc

251 dbbac


Your program then uses a function analyze_data to calculate each student’s score as a percentage and the number of each missed questions in the exam. A function print_data will be called to produce an output, containing the answer key, each student’s ID, each student’s score as a percentage, and information about how many students missed each question.


Sample Output

Exam Report

Students 3

Question 1 2 3 4 5

Answer d b b a c

ID Score(%)

111 80

102 60

251 100

Question 1 2 3 4 5

Missed by 0 2 0 1 0


Error checking
You will have to perform some error checks while the program is being running. However, these error checks will not cause the program to terminate – except if you have a corrupted file. Your program should print error messages when appropriate. Here is a list that need to be checked: Illegal inputs like the number of questions must be between 5-20 and key answers must be lower-case letters.

Solutions

Expert Solution

If you have any doubts, please give me comment...

#include<stdio.h>

void scan_exam_data(int stud_ids[], char stud_answers[][20], int no_students);

void analyze_data(char correct_ans[], char stud_answers[][20], int no_students, int no_questions, int perc[], int misses[]);

void print_data(int stu_ids[], char correct_ans[], int no_studs, int no_ques, int perc[], int misses[]);

int main(){

    int no_students, no_questions, i;

    char correct_answers[21];

    scanf("%d", &no_students);

    scanf("%d %s", &no_questions, correct_answers);

    int stud_ids[no_students];

    char stud_answers[no_students][no_questions+1];

    int percentage[no_students];

    int misses[no_questions];

    for(i=0; i<no_students; i++)

        stud_ids[i] = 0;

    for(i=0; i<no_questions; i++)

        misses[i] = 0;

    scan_exam_data(stud_ids, stud_answers, no_students);

    analyze_data(correct_answers, stud_answers, no_students, no_questions, percentage, misses);

    print_data(stud_ids, correct_answers, no_students, no_questions, percentage, misses);

    return 0;

}

void scan_exam_data(int stud_ids[], char stud_answers[][20], int no_students){

    int i;

    for(i=0; i<no_students; i++){

        scanf("%d %s", &stud_ids[i], stud_answers[i]);

    }

}

void analyze_data(char correct_ans[], char stud_answers[][20], int no_students, int no_questions, int perc[], int misses[]){

    int i, j;

    for(i=0; i<no_students; i++){

        int correct = 0;

        for(j=0; j<no_questions; j++){

            if(correct_ans[j]==stud_answers[i][j])

                correct++;

            else

                misses[j]++;

        }

        perc[i] = ((double)correct/no_questions)*100;

    }

}

void print_data(int stu_ids[], char correct_ans[], int no_studs, int no_ques, int perc[], int misses[]){

    int i;

    printf("Exam Report\n");

    printf("Students %d\n", no_studs);

    printf("Question");

    for(i=1; i<=no_ques; i++)

        printf(" %d", i);

    printf("\nAnswer");

    for(i=0; i<no_ques; i++)

        printf(" %c", correct_ans[i]);

    printf("\n\nID\tScore(%%)\n");

    for(i=0; i<no_studs; i++){

        printf("%d %d\n", stu_ids[i], perc[i]);

    }

    printf("\nQuestion");

    for(i=1; i<=no_ques; i++)

        printf(" %d", i);

    printf("\nMissed by");

    for(i=0; i<no_ques; i++)

        printf(" %d", misses[i]);

    printf("\n");

}


Related Solutions

There are 100 multiple-choice question on exam, each having responses a, b, c, d. Suppose that...
There are 100 multiple-choice question on exam, each having responses a, b, c, d. Suppose that a student has a 70% chance to answer each question correctly, and all the answers are independent. If the student needs to answer at least 40 questions to pass, what is the probability that the student passes? Use normal approximation.
In a multiple choice exam, there are 7 questions and 4 choices for each question (a,...
In a multiple choice exam, there are 7 questions and 4 choices for each question (a, b, c, d). Nancy has not studied for the exam at all and decides to randomly guess the answers. What is the probability that: (please round all answers to four decimal places) a) the first question she gets right is question number 3? b) she gets all of the questions right? c) she gets at least one question right?
Ann has taken a multiple-choice exam consisting of 25 questions. Each question has 5 choices of...
Ann has taken a multiple-choice exam consisting of 25 questions. Each question has 5 choices of which only one is the correct answer. Ann has correctly answered 9 questions. We would like to test if Ann is doing better than randomly guessing the answer to each question. Define the parameter to be tested. State the alternative hypothesis.                                                                         _____________ Compute the test statistic.                                                                                   _____________ Compute the p-value.                                                                                            ____________ At the 1% level of significance, state your conclusion.
n-class: Write a program to store exam scores into a file. The program will ask the...
n-class: Write a program to store exam scores into a file. The program will ask the user how many exam scores to enter. Then it will ask the user for each exam score and store them in a file called scores.dat The file output should have the following format . Exam 1: 97 Exam 2: 85 C++ Coding please
Ada Nixon, a student, has just begun a 30-question, multiple-choice exam. For each question, there is...
Ada Nixon, a student, has just begun a 30-question, multiple-choice exam. For each question, there is exactly one correct answer out of four possible choices. Unfortunately, Ada hasn't prepared well for this exam and has decided to randomly select an answer choice for each question. (a) (4 points) For a given question, what is the probability Ada picks the correct answer, assuming each answer choice is equally likely to be selected? (b) Assume the number of questions Ada answers correctly...
When answering a question on a multiple choice exam, Jon either thinks he knows the answer...
When answering a question on a multiple choice exam, Jon either thinks he knows the answer or just guesses. Suppose the probability that Jon thinks he knows the answer is 0.75 and there’s a 90% chance that he’ll get the question correct if he thinks he knows the answer. There are 5 choices for each multiple-choice exam question. Each question is worth 2 marks (no part marks), but blank answers earn 0.4 marks. Suppose Jon always answers the question if...
Write a C program that calculates a student grade in the C Programming Class. Ask the...
Write a C program that calculates a student grade in the C Programming Class. Ask the user to enter the grades for each one of the assignments completed in class: Quiz #1 - 25 points Quiz #2 - 50 points Quiz #3 - 30 points Project #1 - 100 points Project #2 - 100 points Final Test - 100 points The total of the quizzes count for a 30% of the total grade, the total of the projects counts for...
Write a program in C or C++ that takes a number series of size n (n...
Write a program in C or C++ that takes a number series of size n (n integers) as input from the user, push all the numbers to the stack, and reverse the stack using recursion. Please note that this is not simply popping and printing the numbers, but the program should manipulate the stack to have the numbers stored in reverse order. In addition to the provided header file, the students can use the following function to print the content...
Write a c++ program that given a set of letter grade/credit hour combiniation, determines the grade...
Write a c++ program that given a set of letter grade/credit hour combiniation, determines the grade point average (GPA) Each A is worth 4 points. Each B is worth 3 points. Each C is worth 2 points. Each D is worth 1 point, and Each F is worth 0 points. The total quality points earned is the sum of the product of letter grade points and associated course credit hours. The GPA is the quotient of the quality points divided...
A multiple choice exam consists of 12 questions, each having 5 possible answers. To pass, you...
A multiple choice exam consists of 12 questions, each having 5 possible answers. To pass, you must answer at least 8 out of 12 questions correctly. What is the chance of this, if ; a. You go into the exam without knowing a thing, and have to resort to Pure guessing? b. You have studied enough so that on each question, 3 choices can be eliminated. But then you have to make a pure guess between the remaining 2 choices....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT