I am practicing structures and arrays in c, programmed a code to take multiple student information and store it in an structure array using for loop. But when i run the code only my 0th i index runs properly and rest indexes either skips a scanf fuction or doesnt work properly.
#include<stdio.h>
#include<string.h>
struct FYSD {
char name[100];
int rollNo;
float sgpa;
};
int main()
{
int i;
struct FYSD student[5];
for(i = 0; i < 5; i++) {
printf("Enter student name : ");
gets(student[i].name);
printf("Enter student roll no : ");
scanf("%d",&student[i].rollNo);
printf("Enter student sgpa : ");
scanf("%f",&student[i].sgpa);
}
}
I have no idea what is going on