I want to build a program for my c language project.What i need to do is that the user should enter the number of students,number of questions,correct answers,each students answers answers and then the program should calculate the number of correct answers,and their standing,the most wronged question . the problem i am facing is that i dont know how to match each students answers with the correct answer.this has to be done with dynamic arrays. Help me in this: I am posting the code.
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int main (void)
{
int studnum,a,b;
int quesnum;
int *array1;
int *array2;
int *correctanswers;
printf("Plz enter the number of students: ");
scanf("%d",&studnum);
printf("Plz enter the number of questions: ");
scanf("%d",&quesnum);
correctanswers = (int*) malloc(quesnum*sizeof(int));
array2 = (int*) malloc(quesnum*sizeof(int));
array1 = (int*) malloc(studnum*sizeof(int));
printf("Plz enter the correct answers: ");
for(a=0;a<quesnum;a++)
{
printf("Q%d-",a+1);
scanf(" %c",&correctanswers[a]);
}
for(a=0;a<studnum;a++)
{
printf("Enter student ids: ");
scanf("%d",&array1[a]);
for ( b=0;b<quesnum;b++)
{
printf("Enter questions answers:");
printf("#%d.",b+1);
scanf(" %c",&array2[b]);
}
}
getche();
return 0;
}