struct book
{
int id;
float price;
char name[15];
};
int main()
{
struct book b[2];
for(i=0;i<2;i++)
{
printf("Enter id,price and name of the book");
scanf("%d\t%f\t%s",&b[i].id,&b[i].price,b[i].name);
}
for(i=0;i<2;i++)
printf("%d\t%f\t%s",b[i].id,b[i].price,b[i].name);
return 0;
}
b = array of book structuresb[0] = 0th book structure in array b
We can access member of 0th book structure by b[0].member.
Generalizing it,we can access member of ith book structure of array b by
b[i].member
No comments:
Post a Comment