Page 13 - Data Struct
P. 13

13
                   Algorithm and Data Structure


                   Example 2

                      #include <iostream.h>
                      void main ( )
                      {
                          struct  book
                         {
                             char name [30];
                             int pages;
                             char author[ ];
                             float price;
                         } book[3];

                      cout<< “Insert Data for Three Books”;
                            for(int i=0;i<3;i++)
                            {
                                   cout<< “Insert book name”<<j+1;
                                   cin>>book[j].name;
                                   cout<< “Insert book pages” <<j+1;
                                   cin>> book[j].pages;
                                   cout<< “Insert book author” <<j+1;

                                   cin>> book[j].author;
                                   cout<< “Insert book price” <<j+1;
                                   cin>> book[j]..price
                            }
                   2.0    LIST AND LINKED LIST (CLO1: PLO1, CLO2: PLO1)
   8   9   10   11   12   13   14