1.This program displays the pre-available books in the library with their quantity and serial number.
2.The user input the the serial number of the book and quantity of the book.
3.If the book is available then it will be successfully issued and the list of available books are re-displayed.
(NOTE=>You can search the book with the name (without serial number) with the use of strcmp() function.)
CODE=>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
struct library
{
char *bname;
char *aname;
int qty;
}lib[7];
void main()
{
int i,sn,qty;
char ans;
lib[0].bname="PHYSICS";
lib[0].aname="S.K VERMA";
lib[0].qty=10;
lib[1].bname="LET US C";
lib[1].aname="YASHWANT KANETKAR";
lib[1].qty=15;
lib[2].bname="C HOW TO PROGRAM";
lib[2].aname="H.M DEITEL";
lib[2].qty=6;
lib[3].bname="BASIC ELECTRONICS";
lib[3].aname="B.K GUPTA";
lib[3].qty=18;
lib[4].bname="BUSINESS COMMUNICATION";
lib[4].aname="K.K SINHA";
lib[4].qty=12;
lib[5].bname="ORGANIC CHEMISTRY";
lib[5].aname="R.C CHANDRA";
lib[5].qty=9;
lib[6].bname="HARRY POTTER AND GOBLET OF FIRE";
lib[6].aname="J.K ROWLING";
lib[6].qty=2;
lib[7].bname="LEARN HTML BASICS";
lib[7].aname="MANISH SRIVASTAV";
lib[7].qty=11;
clrscr();
printf("S.NO BOOK NAME AUTHOR NAME QUANTITY\n");
for( i=0;i<7;i++)
{
printf("%d %s %s %d\n",i+1,lib[i].bname,lib[i].aname,lib[i].qty);
}
printf("\nENTER THE SERIAL NUMBER OF BOOK YOU WANT TO CHOOSE\n");
scanf("%d",&sn);
printf("\nENTER THE QUANTITY OF THE BOOK\n");
scanf("%d",&qty);
if(sn==1 && qty<=10)
{
printf("YOUR BOOK IS SUCCESSFULLY ISSUED\n");
lib[0].qty=lib[0].qty-qty;
}
if(sn==2 && qty<=15)
{
printf("YOUR BOOK IS SUCCESSFULLY ISSUSED\n");
lib[1].qty=lib[1].qty-qty;
}
if(sn==3 && qty<=6)
{
printf("YOUR BOOK IS SUCCESSFULLY ISSUED\n");
lib[2].qty=lib[2].qty-qty;
}
if(sn==4 && qty<=18)
{
printf("YOUR BOOK IS SUCCESSFULLY ISSUED\n");
lib[3].qty=lib[3].qty-qty;
}
if(sn==5 && qty<=12)
{
printf("YOUR BOOK IS SUCCESSFULLY ISSUED\n");
lib[4].qty=lib[4].qty-qty;
}
if(sn==5 && qty<=9)
{
printf("YOUR BOOK IS SUCCESSFULLY ISSUED\n");
lib[5].qty=lib[5].qty-qty;
}
if(sn==6 && qty<=2)
{
printf("YOUR BOOK IS SUCCESSFULLY ISSUED\n");
lib[6].qty=lib[6].qty-qty;
}
if(sn==7 && qty<=11)
{
printf("YOUR BOOK IS SUCCESSFULLY ISSUED\n");
lib[7].qty=lib[7].qty-qty;
}
if(sn>7)
{
printf("YOU HAVE ENTERED WRONG CHOICE\n");
}
printf("\nNOW LIST OF AVALIABLE BOOKS ARE\n");
for(i=0;i<7;i++)
{
printf("%d %s %s %d\n",i+1,lib[i].bname,lib[i].aname,lib[i].qty);
}
getch();
}
OUTPUT=>
2.The user input the the serial number of the book and quantity of the book.
3.If the book is available then it will be successfully issued and the list of available books are re-displayed.
(NOTE=>You can search the book with the name (without serial number) with the use of strcmp() function.)
CODE=>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
struct library
{
char *bname;
char *aname;
int qty;
}lib[7];
void main()
{
int i,sn,qty;
char ans;
lib[0].bname="PHYSICS";
lib[0].aname="S.K VERMA";
lib[0].qty=10;
lib[1].bname="LET US C";
lib[1].aname="YASHWANT KANETKAR";
lib[1].qty=15;
lib[2].bname="C HOW TO PROGRAM";
lib[2].aname="H.M DEITEL";
lib[2].qty=6;
lib[3].bname="BASIC ELECTRONICS";
lib[3].aname="B.K GUPTA";
lib[3].qty=18;
lib[4].bname="BUSINESS COMMUNICATION";
lib[4].aname="K.K SINHA";
lib[4].qty=12;
lib[5].bname="ORGANIC CHEMISTRY";
lib[5].aname="R.C CHANDRA";
lib[5].qty=9;
lib[6].bname="HARRY POTTER AND GOBLET OF FIRE";
lib[6].aname="J.K ROWLING";
lib[6].qty=2;
lib[7].bname="LEARN HTML BASICS";
lib[7].aname="MANISH SRIVASTAV";
lib[7].qty=11;
clrscr();
printf("S.NO BOOK NAME AUTHOR NAME QUANTITY\n");
for( i=0;i<7;i++)
{
printf("%d %s %s %d\n",i+1,lib[i].bname,lib[i].aname,lib[i].qty);
}
printf("\nENTER THE SERIAL NUMBER OF BOOK YOU WANT TO CHOOSE\n");
scanf("%d",&sn);
printf("\nENTER THE QUANTITY OF THE BOOK\n");
scanf("%d",&qty);
if(sn==1 && qty<=10)
{
printf("YOUR BOOK IS SUCCESSFULLY ISSUED\n");
lib[0].qty=lib[0].qty-qty;
}
if(sn==2 && qty<=15)
{
printf("YOUR BOOK IS SUCCESSFULLY ISSUSED\n");
lib[1].qty=lib[1].qty-qty;
}
if(sn==3 && qty<=6)
{
printf("YOUR BOOK IS SUCCESSFULLY ISSUED\n");
lib[2].qty=lib[2].qty-qty;
}
if(sn==4 && qty<=18)
{
printf("YOUR BOOK IS SUCCESSFULLY ISSUED\n");
lib[3].qty=lib[3].qty-qty;
}
if(sn==5 && qty<=12)
{
printf("YOUR BOOK IS SUCCESSFULLY ISSUED\n");
lib[4].qty=lib[4].qty-qty;
}
if(sn==5 && qty<=9)
{
printf("YOUR BOOK IS SUCCESSFULLY ISSUED\n");
lib[5].qty=lib[5].qty-qty;
}
if(sn==6 && qty<=2)
{
printf("YOUR BOOK IS SUCCESSFULLY ISSUED\n");
lib[6].qty=lib[6].qty-qty;
}
if(sn==7 && qty<=11)
{
printf("YOUR BOOK IS SUCCESSFULLY ISSUED\n");
lib[7].qty=lib[7].qty-qty;
}
if(sn>7)
{
printf("YOU HAVE ENTERED WRONG CHOICE\n");
}
printf("\nNOW LIST OF AVALIABLE BOOKS ARE\n");
for(i=0;i<7;i++)
{
printf("%d %s %s %d\n",i+1,lib[i].bname,lib[i].aname,lib[i].qty);
}
getch();
}
OUTPUT=>