In this program, you'll learn to declare structure book having data member as book_name, bookid, book_price. Accept this data for 3 books and display it.
#include<stdio.h>
struct book
{
char book_name[20];
int bookid;
int book_price;
}b[3];
int main()
{
int i;
for(i=0;i<3;i++)
{
printf("Enter details for book %d :",i+1);
scanf("%s %d %d", b[i].book_name,&b[i].bookid,&b[i].book_price);
}
printf("\nDetails of books :\n");
for(i=0;i<3;i++)
{
printf("%s %d %d\n", b[i].book_name,b[i].bookid,b[i].book_price);
}
}
Enter details for book 1 :PCI 101 300
Enter details for book 2 :BCC 102 350
Enter details for book 3 :WPD 103 250
Details of books :
PCI 101 300
BCC 102 350
WPD 103 250