/*write a manu driven progarm in 'c' that shows the working of library the manu option sgould be
a)add book information
b)display book information
c)list all book of given auhtor
d)list the count of book in library
e)exit */
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
void add_book();
void dis_book();
void disp_auth();
void count_book();
struct library1
{
char book_name[20];
char auth_name[20];
};
int i;
struct library1 book[5];
void main()
{
int choice;
while(1)
{
clrscr();
printf("\n1 :add book information :");
printf("\n2:display book information :");
printf("\n3 :display the book whose author name is given :");
printf("\n4 :count of book");
printf("\n5 :Exit");
printf("\nenter your choice");
scanf("%d",&choice);
switch(choice)
{
case 1:
add_book();
printf("\n\n\n");
getch();
break;
case 2:
dis_book();
printf("\n\n\n");
getch();
break;
case 3:
disp_auth();
printf("\n\n");
getch();
break;
case 4:
count_book();
printf("\n\n");
getch();
break;
case 5:dis_book();
count_book();
disp_auth();
exit();
}
}
}
void add_book()
{
if(i==5)
{
printf("\nno more space");
return;
}
printf("\nenter the book details :");
printf("\nenter the book name :");
scanf("%s",&book[i].book_name);
printf("\nenter the author name :");
scanf("%s",&book[i].auth_name);
i++;
}
void dis_book()
{
int j;
for(j=0;j<i;j++)
{
printf("\n\n\nthe display of book details :");
printf("\nthe book name is :%s",book[j].book_name);
printf("\nthe author name is :%s",book[j].auth_name);
}
}
void disp_auth()
{
char nm[20];
int dec=0,j;
printf("\n\n\nenter the author name :");
scanf("%s",&nm);
for(j=0;j<i;j++)
{
if(strcmp(nm,book[j].auth_name)==0)
{
dec++;
printf("\nthe book name is :%s",book[j].book_name);
printf("\n\n");
}
}
if(dec==0)
printf("\nno such book");
}
void count_book()
{
int j,k=0;
for(j=0;j<i;j++)
{
k++;
}
printf("\n\n\nthe count of book in library :%d",k);
return;
}
/*
1 :add book information :
2:display book information :
3 :display the book whose author name is given :
4 :count of book
5 :Exit
enter your choice5
the display of book details :
the book name is :sdfs
the author name is :peer
the display of book details :
the book name is :sfdsg
the author name is :peer
the display of book details :
the book name is :hgf
the author name is :santosh
the display of book details :
the book name is :jgdjf
the author name is :santosh
the display of book details :
the book name is :fgsdf
the author name is :muneer
the count of book in library :5
enter the author name :santosh
the book name is :hgf
the book name is :jgdjf
*/
No comments:
Post a Comment