Professional Documents
Culture Documents
Sem 2 LMS Report
Sem 2 LMS Report
SYSTEM
Submitted by
Chinmay Paradkar
Yogesh Mahajan
ABSTRACT
FILE *record;
void main()
{
int choice;
printf("Library management project");
do
{
printf("\n\tMENU\n 1> Add A New Book\n 2> Search a book \n 3> Display Complete
Information\n 4> Display All Books of An Author\n 0> Exit the program\n\n\t Enter your
choice (1-10): ");
scanf("%d",&choice);
switch (choice)
{
case 1:
addbook();
break;
case 2:
searchbook();
break;
case 3:
display();
break;
case 4:
author();
break;
}
}while(choice!=0);
}
void addbook()
{
record=fopen("abcda.txt","a+");
printf("Enter the book ID");
scanf("%d",&book.id);
printf("Enter the book name");
scanf("%s",&book.name);
printf("Enter the name of author");
scanf("%s",&book.author);
fprintf(record,"\n%d\t%s\t%s\t",book.id,book.name,book.author);
printf("A NEW BOOK IS ADDED SUCCESFULLY");
fclose(record);
}
void searchbook()
{
char find[25];
int Found=0;
if((record=fopen("abcda.txt","r"))==NULL)
printf(" The File is Empty...\n\n");
else
{
printf("\nEnter The Name Of Book : ");
scanf("%s",&find);
while(!feof(record)&& Found==0)
{
fscanf(record,"%d %s %s", &book.id,book.name,book.author);
if(strcmp(find,book.name)==0)
{ Found=1;}
}
if(Found)
{
printf("\nThe Unique ID of The Book: %d\nThe Name of Book is: %s\nThe Author is:
%s\n\n",book.id,book.name,book.author);
}
else if(!Found)
printf("There is no such Entry...\n");
fclose(record);
}
}
void author()
{
int i;
char Target[500];
int Found=0;
if((record=fopen("abcda.txt","r"))==NULL)
printf(" ! The file is empty... \n\n");
else
{
printf("\nEnter The Name Of Author : ");
scanf("%s",&Target);
printf("\nBooks:");
while(!feof(record))
{
fscanf(record,"%d %s %s",&book.id,book.name,book.author);
if(strcmp(Target,book.author)==0)
{
Found=1;
printf("\n\t%s",book.name);
}
}
if(!Found)
printf(" There is no such Entry...\n");
fclose(record);
}
}
void display()
{
record = fopen("abcda.txt","a+");
printf("\nBookid\tName\tAuthor\n",in);
do
{
fgets(in,50,record);
printf("%s\n",in);
}while(!feof(record));
fclose(record);
}
OUTPUT
Library management project
MENU
1> Add A New Book
2> Search a book
3> Display Complete Information
4> Display All Books of An Author
5> Exit the program
MENU
1> Add A New Book
2> Search a book
3> Display Complete Information
4> Display All Books of An Author
5> Exit the program
Enter your choice (1-5): 3
34 ABC CHINMAY
23 DEF YOGESH
67 SE MAHAJAN
67 DDB CHINMAY
45 SPCC CHINMAY
MENU
1> Add A New Book
2> Search a book
3> Display Complete Information
4> Display All Books of An Author
5> Exit the program
Books:
ABC
SPCC
DDB
1> Add A New Book
2> Search a book
3> Display Complete Information
4> Display All Books of An Author
5> Exit the program