In a class, we don't have just one student but there may be more than one, to process such students information using structures you need to create structure variable as an array.
In array of structures the structure variable is itself an array that is we can use this variable to store the similar type of data ( of type structure) to handle.
Example: Write a C program to read the details of "N" students and print them.
struct student { int no; char name[20]; }s[100]; void main() { int n,i; printf(" enter number of students"); scanf("%d",&an); printf("enter student details"); for(i=0;i<n;i++ { scanf("%d",&s[i].no); gets(s[i].name); } printf(" student details are"); for(i=0;i<n;i++ { printf("%d",s[i].no); puts(s[i].name); } getch(); }
0 comments :
Post a Comment
Note: only a member of this blog may post a comment.