Explain Array Of Structure In C Programming by getting input from user-99webcode
#include<stdio.h>
struct student
{
int roll;
float mark;
char name[20];
};
void main()
{
struct student s[3];
for(int i=0;i<=3;i++)
{
printf("enter the information ");
scanf("%d %f %s",&s[i].roll,&s[i].mark,s[i].name); //store information for 4 students
}
for (int i=0;i<=3;i++)
{
printf("%d\n %f\n %s\n",s[i].roll,s[i].mark,s[i].name); //print information of 4 studens
}
}
output:
enter the information
21
88.7
salil
enter the information
25
98.4
aaru
enter the information
45
88.4
nikhil
enter the information
65
98.9
aisha
your roll no is: 21
your marks is :88.699997
your name is:salil
your roll no is: 25
your marks is :98.400002
your name is:aaru
your roll no is: 45
your marks is :88.400002
your name is:nikhil
your roll no is: 3
your marks is :98.900009
your name is:aisha