C++ Programming Blog

 
 
 

Image

 #include<iostream.h>
 #include <string.h>
 #include<conio.h>
 #include<stdio.h>

 main( )
    {
       clrscr();

       const int no_of_books=10;

       int flag=0;

       char libarary[no_of_books][40]=
               {\"Physics\",\"Math\",\"English\",\"Urdu\",\"Biology\",\"Biology\",
            \"Calculus\",\"Data Base\",\"Automata\",\"Mathematics\" };
       char book_name[10];

       cout<<\"\\n Enter the name of the book you want to find : \";
       gets(book_name);

       for(int count=0;count<no_of_books;count++)
      {
         if(strcmpi(&libarary[count][0],book_name)==0)
        {
           flag=1;
           break;
        }
      }

       if(flag==1)
      {
         cout<<\"\\n The given book is found and its library number is \";
         cout<<count<<endl;
      }

       else
      cout<<\"\\n The given book is not found \"<<endl;

       getch();
       return 0;
    }

 
 
Didn't find what you were looking for? Find more on Program to find a Book in the list of Books