I wanted to make a program that can read the right answers, check the students answers comparing with the right answers and then show the points of each. The problem is that every time that I insert the first answer the program skips the second one and jumps to the third. Here's how it turns out every time:
"Insert the answer 1: a
Insert the answer 2: Insert the answer 3:"
And here's my code:
#include <stdio.h>
int main()
{
char v[30], a[30][20];
int i,j,c;
for (i=0; i<30; i++)
{
printf("Insert the answer %d: ", i+1);
scanf("%c", &v[i]);
}
for(j=0; j<20; j++)
{
printf("Student %d\n", j+1);
for (i=0; i<30; i++)
{
printf("Insert your answer %d: ", i+1);
scanf("%c", &a[i][j]);
}
}
for(j=0; j<20; j++)
{
c=0;
printf("Student %d\n", j+1);
for (i=0; i<30; i++)
{
if (v[i] == a[i][j])
c=c+1;
}
printf("Points: %d\n", c);
}
return 0;
}