c program to implement multiple choice questions evaluation

Description


This program implements multiple choice test. The are total 10 questions, the users have to give their option for each question, one by one and it will be read to the array a[]. The correct option is stored in the array b[]. Each choice by the user is compared with the stored answers, if it matches, the count of correct answers will be incremented,  otherwise the count for wrong answers will be incremented.

Program


#include<stdio.h>

#include<conio.h>

void main()

{

clrscr();

char a[10],b[10]={'a','b','c','d','a','b','c','d','a','b'};

int ct=0,cf=0,i=0;

printf("Enter the answers");

while(i<10)

{

printf("%d: ",i+1);

scanf("%s",&a[i]);

}

if(a[i]==b[i])

{

ct++;

}

else

{

cf++;

}

i++;

}

printf("Number of correct answers=%d",ct);

printf("\nNumber of wrong answers=%d",cf);

getch();

}


No comments: