google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: C program menu drive example

Wednesday, April 1, 2015

C program menu drive example

Write a menu driven program in ‘C’ that shows the working of a library.
The menu option should be
- Add book information.
- Display book information.
- List all books of given author.
- List the count of books in the library.
- Exit.
(Using Structure Array)

#include
#include
struct book
{
int bno;
char bname[20],author[20];
};
void main()
{
struct book b[10];
int i,n,m;
char t[10];
clrscr();
do
{
printf("\n1.ADD BOOK INFORMATION");
printf("\n2.DISPLAY BOOK INFORMATION");
printf("\n3.LIST ALL BOOKS OF GIVEN AUTHOR");
printf("\n4.TOTAL NO OF BOOKS IN LIBRARY");
printf("\n5.EXIT");
printf("\nENTER UR CHOICE");
scanf("%d",&m);
switch(m)
{
case 1:
printf("\nHOW MANY BOOKS WANT");
scanf("%d",&n);

printf("\nENTER THE BNO,BNAME & AUTHOR");
for(i=0;i {
scanf("%d%s%s",&b[i].bno,&b[i].bname,&b[i].author);
}
break;
case 2:
printf("\nBOOK DETAILS \n");
for(i=0;i {
printf("\n%d\t%s\t%s",b[i].bno,b[i].bname,b[i].author);
}
break;
case 3:
printf("\nENTER THE AUTHOR NAME");
scanf("%s",&t);
printf("\n BOOK LIST");
for(i=0;i {
if(strcmp(&b[i].author,&t)==0)
{
printf("\n BOOK NAME");
printf("\n%s",b[i].bname);
}
}
break;
case 4:
printf("\n%d",n);
break;
case 5:
exit(0);
}
}
while(m!=5);
getch();
}

हिम्मत

 अंधेरे में एक करोड का हीरा गिर गया था, उसे ढूंढने के लिए पाँच रूपएं की मोमबत्ती ने सहयोग किया। अभी बताओ वह पाँच रूपएं की एक छोटी सी मोमबत्त...