Structures in C Language
Structures in C Language
{ {
structure element 1 ; char name ;
structure element 2 ; float price ;
structure element 3 ; int pages ;
...... };
......
};
struct <structure name> struct <structure name>
{ {
structure element 1 ; structure element 1 ;
structure element 2 ; structure element 2 ;
structure element 3 ; structure element 3 ;
...... ......
...... ......
}; } b1, b2, b3 ;
struct book b1, b2, b3 ;
int main() {
return 0;
}
An array of structures in C can be defined as the collection
of multiple structures variables where each variable contains
information about different entities. The array of
structures in C are used to store information about multiple
entities of different data types. The array of structures is also
known as the collection of structures.
#include<stdio.h> printf("\nStudent Information List:");
#include <string.h> for(i=0;i<5;i++){
struct student{ printf("\nRollno:%d, Name:
int rollno; %s",st[i].rollno,st[i].name);
char name[10]; }
}; return 0;
int main(){ }
int i;
struct student st[5];
printf("Enter Records of 5 students");
for(i=0;i<5;i++){
printf("\nEnter Rollno:");
scanf("%d",&st[i].rollno);
printf("\nEnter Name:");
scanf("%s",&st[i].name);
}
OUTPUT
Additional Features of Structures