#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <time.h>
struct book
{
int b_no;
char b_name[40];
char b_author[40];
int no_pages;
};
int main()
{
struct book b[20];
int ch,n,i,count = 0;
char temp[40];
do
{
printf("\n\t");
printf("\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\n");
printf("\t\t\t\xB2 MAIN MENU \xB2");
printf("\n\t");
printf("\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\n\n");
printf("\t\xDB\xDB\xDB\xDB\xB2 PRESS 1.To add Book\n");
printf("\n\t\xDB\xDB\xDB\xDB\xB2 PRESS 2. To Display Book Details\n");
printf("\n\t\xDB\xDB\xDB\xDB\xB2 PRESS 3. To Display Book Of Given Author\n");
printf("\n\t\xDB\xDB\xDB\xDB\xB2 PRESS 4. To count Number Of Books\n");
printf("\n\t\xDB\xDB\xDB\xDB\xB2 PRESS 5. To Close Application\n\n");
printf("\t\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\n");
time_t t;
time(&t);
printf("\t%s", ctime(&t));
printf("\t..........................................\n");
printf("\tEnter Your Choice: ");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("\n\tHow Many Records You Want to Add: ");
scanf("%d",&n);
printf("\t-------------------------------------\n");
printf("\tAdd Details of %d Book\n",n);
printf("\t-------------------------------------\n");
for(i = 0 ; i < n ; i++)
{
printf("\tEnter Book No. : ");
scanf("%d",&b[i].b_no);
printf("\tBook Name : ");
scanf("%s",b[i].b_name);
printf("\tEnter Author Name : ");
scanf("%s",b[i].b_author);
printf("\tEnter No. of Pages : ");
scanf("%d",&b[i].no_pages);
printf("\t-------------------------------------\n");
}
break;
case 2:
printf("\n\t\t\xB2\xB2\xB2\xB2\xB2\xB2 Details of All Book \xB2\xB2\xB2\xB2\xB2\xB2");
printf("\n\t-----------------------------------------------------------\n");
printf("\t\tBook No. Book Name\t Author Name\tNo. of Pages");
printf("\n\t------------------------------------------------------------");
for( i = 0 ; i < n ; i++)
{
printf("\n\t %d\t %s\t %s\t %d",b[i].b_no,b[i].b_name,b[i].b_author,b[i].no_pages);
}
printf("\n\n");
break;
case 3:
printf("\n\tEnter Author Name: ");
scanf("%s",temp);
printf("\t--------------------------------------");
for( i = 0 ; i < n ; i++)
{
if(strcmp(b[i].b_author,temp) == 0)
{
printf("\n%s\n",b[i].b_name);
}
}
break;
case 4 :
for( i = 0 ; i < n ; i++)
{
count++;
}
printf("\t******************************************");
printf("\n\tTotal Number of Books in Library : %d\n",count);
printf("\t******************************************\n");
break;
case 5 :
exit(0);
}
}while(ch != 5);
return 0;
}
#include<stdlib.h>
#include<string.h>
#include <time.h>
struct book
{
int b_no;
char b_name[40];
char b_author[40];
int no_pages;
};
int main()
{
struct book b[20];
int ch,n,i,count = 0;
char temp[40];
do
{
printf("\n\t");
printf("\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\n");
printf("\t\t\t\xB2 MAIN MENU \xB2");
printf("\n\t");
printf("\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\n\n");
printf("\t\xDB\xDB\xDB\xDB\xB2 PRESS 1.To add Book\n");
printf("\n\t\xDB\xDB\xDB\xDB\xB2 PRESS 2. To Display Book Details\n");
printf("\n\t\xDB\xDB\xDB\xDB\xB2 PRESS 3. To Display Book Of Given Author\n");
printf("\n\t\xDB\xDB\xDB\xDB\xB2 PRESS 4. To count Number Of Books\n");
printf("\n\t\xDB\xDB\xDB\xDB\xB2 PRESS 5. To Close Application\n\n");
printf("\t\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\n");
time_t t;
time(&t);
printf("\t%s", ctime(&t));
printf("\t..........................................\n");
printf("\tEnter Your Choice: ");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("\n\tHow Many Records You Want to Add: ");
scanf("%d",&n);
printf("\t-------------------------------------\n");
printf("\tAdd Details of %d Book\n",n);
printf("\t-------------------------------------\n");
for(i = 0 ; i < n ; i++)
{
printf("\tEnter Book No. : ");
scanf("%d",&b[i].b_no);
printf("\tBook Name : ");
scanf("%s",b[i].b_name);
printf("\tEnter Author Name : ");
scanf("%s",b[i].b_author);
printf("\tEnter No. of Pages : ");
scanf("%d",&b[i].no_pages);
printf("\t-------------------------------------\n");
}
break;
case 2:
printf("\n\t\t\xB2\xB2\xB2\xB2\xB2\xB2 Details of All Book \xB2\xB2\xB2\xB2\xB2\xB2");
printf("\n\t-----------------------------------------------------------\n");
printf("\t\tBook No. Book Name\t Author Name\tNo. of Pages");
printf("\n\t------------------------------------------------------------");
for( i = 0 ; i < n ; i++)
{
printf("\n\t %d\t %s\t %s\t %d",b[i].b_no,b[i].b_name,b[i].b_author,b[i].no_pages);
}
printf("\n\n");
break;
case 3:
printf("\n\tEnter Author Name: ");
scanf("%s",temp);
printf("\t--------------------------------------");
for( i = 0 ; i < n ; i++)
{
if(strcmp(b[i].b_author,temp) == 0)
{
printf("\n%s\n",b[i].b_name);
}
}
break;
case 4 :
for( i = 0 ; i < n ; i++)
{
count++;
}
printf("\t******************************************");
printf("\n\tTotal Number of Books in Library : %d\n",count);
printf("\t******************************************\n");
break;
case 5 :
exit(0);
}
}while(ch != 5);
return 0;
}
Comments
Post a Comment