U1p2

#include<stdio.h> #include<conio.h> struct book { char title[30],author[20],publisher[20]; int year,pages,price; }; void main() { int i; struct book b[3]; clrscr(); for(i=1;i<3;i++) { printf("enter title,author and publisher"); scanf("%s %s %s",&b[i].title,&b[i].author,&b[i].publisher); printf("enter year,pages and price"); scanf("%d %d %d",&b[i].year,&b[i].pages,&b[i].price); } for(i=1;i<3;i++) { printf("title=%s\n",b[i].title); printf("author=%s\n",b[i].author); printf("publisher=%s\n",b[i].publisher); printf("year=%d\n",b[i].year); printf("pages=%d\n",b[i].pages); printf("price=%d\n",b[i].price); } getch(); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.