Tuesday, 9 June 2015

Program to find a Book in the list of Books


Code for Program to find a Book in the list of Books in C++ Programming



 



 



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

 main( )
    {
       clrscr();

       constint 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;
    }

No comments:

Post a Comment