im making simple program to read roll number and name of 5 students but it only prints roll no of 1st student whats wrong in code?
Code:
#include<stdio.h>
void main()
{
struct student
{
int roll;
char name;
};
struct student stu[3];
int i;
printf("Enter details of 5 students\n");
for(i=0;i<3;i++)
{
printf("Enter roll no for student %d\n",i+1);
scanf("%d",&stu[i].roll);
printf("Enter name of student %d\n",i+1);
scanf("%s",&stu[i].name);
}
printf("details of student\n");
for(i=0;i<3;i++)
{
printf("details of stuednt %d\n",i+1);
printf("Roll no %d\n",stu[i].roll);
printf("name %s",stu[i].name);
}
}
i have to print roll no and name of 3 students not only of 1st studnt
help me guys!!!