Blog

C Structure with Array and Loop Program

Qunata INfotech Blog C Structure Output
Qunata INfotech Blog C Structure Output
Output     #include<stdio.h> void main() { int i,j; struct book1 { char book[30]; int pages; float price; }; struct book1 bk1[50]; printf(“How many Details You Want to Enter : “); scanf(“%d”, &j); for(i=1; i<=j; i++) { printf(“\n\n______ Enter Details of Book %d _______\n\n”,i); printf(“Enter Book Name : “); scanf(“%s”, bk1[i].book); printf(“Enter Number of Pages : “); scanf(“%d”, &bk1[i].pages); printf(“Enter Price of Book : “); scanf(“%f”, &bk1[i].price); } printf(“\n\n ********** Books Details **************\n\n”); for(i=1; i<=j; i++) { printf(“________ Details of Book %d _________\n\n”,i); printf(“Book Name is %s \n”, bk1[i].book); printf(“No of Pages in Book %d \n”, bk1[i].pages); printf(“Price of Book is %.2f \n”, bk1[i].price); printf(“\n”); } }  

Leave a Reply

Your email address will not be published. Required fields are marked *