#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
void book_auth();
void book_pub();
void book_cost();
void disp_book();
void add_book();
struct book
{
char book_title[20];
int acc_no;
char author[20];
char pub[20];
int cost;
};
int count;
struct book b[100];
void main()
{
int ch;
while(1)
{
clrscr();
printf("\n 1:add book \n");
printf("\n 2:specific author \n");
printf("\n 3:specific publisher \n");
printf("\n 4:cost above 500 \n");
printf("\n 5:all book \n");
printf("\n 6:exit \n");
printf("\n\n enter the choice \n");
scanf("%d",&ch);
switch(ch)
{
case 1: add_book(); getch();
break;
case 2: book_auth(); getch();
break;
case 3: book_pub(); getch();
break;
case 4: book_cost(); getch();
break;
case 5: disp_book(); getch();
break;
case 6:exit(0);
}
}
}
void add_book()
{
if(count==9)
{
printf("\n no more space");
return;
}
printf("\n enter book detail ");
printf("\n enter accession number of book \n");
scanf("%d",&b[count].acc_no);
printf("\n enter name of book\n");
scanf("%s",b[count].book_title);
printf("\n enter name of author\n");
scanf("%s",b[count].author);
printf("\n enter the publisher\n");
scanf("%s",b[count].pub);
printf("\n enter book cost \n");
scanf("%d",&b[count].cost);
count++;
}
void disp_book()
{
int i;
printf("\n detail of %d book ",count);
for(i=0;i<count;i++)
{
printf("\n %d\n%s\n%s\n%s\n%d",b[i].acc_no,b[i].book_title,b[i].author,b[i].pub,b[i].cost);
}
}
void book_auth()
{
int i,cnt;
char name[20];
printf("\n enter the name of author");
scanf("%s",name);
for(i=0;i<count;i++)
{
if(strcmp(name,b[i].author)==0)
{
cnt++;
printf("\n%d\n%s\n%s\n%s\n%d",b[i].acc_no,b[i].book_title,b[i].author,b[i].pub,b[i].cost);
}
if(cnt==0)
printf("\n no such book");
}
}
void book_pub()
{
int i,cnt;
char name[20];
printf("\n enter the name of publisher=");
scanf("%s",name);
for(i=0;i<count;i++)
{
if(strcmp(name,b[i].pub)==0)
{
cnt++;
printf("\n%d\n%s\n%s\n%s\n%d",b[i].acc_no,b[i].book_title,b[i].author,b[i].pub,b[i].cost);
}
}
if(cnt==0)
printf("\n no such book");
}
void book_cost()
{
int i;
for(i=0;i<count;i++)
{
if(b[i].cost>500)
{
printf("\n%s",b[i].book_title);
}
}
}
#include<conio.h>
#include<stdlib.h>
#include<string.h>
void book_auth();
void book_pub();
void book_cost();
void disp_book();
void add_book();
struct book
{
char book_title[20];
int acc_no;
char author[20];
char pub[20];
int cost;
};
int count;
struct book b[100];
void main()
{
int ch;
while(1)
{
clrscr();
printf("\n 1:add book \n");
printf("\n 2:specific author \n");
printf("\n 3:specific publisher \n");
printf("\n 4:cost above 500 \n");
printf("\n 5:all book \n");
printf("\n 6:exit \n");
printf("\n\n enter the choice \n");
scanf("%d",&ch);
switch(ch)
{
case 1: add_book(); getch();
break;
case 2: book_auth(); getch();
break;
case 3: book_pub(); getch();
break;
case 4: book_cost(); getch();
break;
case 5: disp_book(); getch();
break;
case 6:exit(0);
}
}
}
void add_book()
{
if(count==9)
{
printf("\n no more space");
return;
}
printf("\n enter book detail ");
printf("\n enter accession number of book \n");
scanf("%d",&b[count].acc_no);
printf("\n enter name of book\n");
scanf("%s",b[count].book_title);
printf("\n enter name of author\n");
scanf("%s",b[count].author);
printf("\n enter the publisher\n");
scanf("%s",b[count].pub);
printf("\n enter book cost \n");
scanf("%d",&b[count].cost);
count++;
}
void disp_book()
{
int i;
printf("\n detail of %d book ",count);
for(i=0;i<count;i++)
{
printf("\n %d\n%s\n%s\n%s\n%d",b[i].acc_no,b[i].book_title,b[i].author,b[i].pub,b[i].cost);
}
}
void book_auth()
{
int i,cnt;
char name[20];
printf("\n enter the name of author");
scanf("%s",name);
for(i=0;i<count;i++)
{
if(strcmp(name,b[i].author)==0)
{
cnt++;
printf("\n%d\n%s\n%s\n%s\n%d",b[i].acc_no,b[i].book_title,b[i].author,b[i].pub,b[i].cost);
}
if(cnt==0)
printf("\n no such book");
}
}
void book_pub()
{
int i,cnt;
char name[20];
printf("\n enter the name of publisher=");
scanf("%s",name);
for(i=0;i<count;i++)
{
if(strcmp(name,b[i].pub)==0)
{
cnt++;
printf("\n%d\n%s\n%s\n%s\n%d",b[i].acc_no,b[i].book_title,b[i].author,b[i].pub,b[i].cost);
}
}
if(cnt==0)
printf("\n no such book");
}
void book_cost()
{
int i;
for(i=0;i<count;i++)
{
if(b[i].cost>500)
{
printf("\n%s",b[i].book_title);
}
}
}