-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibrary-management-system.c
128 lines (89 loc) · 2.19 KB
/
library-management-system.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
Library Management System made by
Shourya Kole
(RA2111028010015)
*/
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
struct library
{
char bk_name[30];
char author[30];
int pages;
float price;
};
int main()
{
struct library l[100];
char ar_nm[30], bk_nm[30];
int i, j, keepcount;
i = j = keepcount = 0;
while (j != 6)
{
printf("\n\n1. Add Book Information\n2. List Book Information\n");
printf("3. List all books of given author\n");
printf("4. List the title of specified book\n");
printf("5. List the count of books in the library\n");
printf("6. List the Project Information\n");
printf("7. Exit the Program\n");
printf("\n\nEnter one of the above : ");
scanf("%d", &j);
switch (j)
{
/* Add book information */
case 1:
printf("Enter book name = ");
scanf("%s", l[i].bk_name);
printf("Enter author name = ");
scanf("%s", l[i].author);
printf("Enter pages = ");
scanf("%d", &l[i].pages);
printf("Enter price = ");
scanf("%f", &l[i].price);
keepcount++;
break;
case 2:
printf("you have entered the following information\n");
for (i = 0; i < keepcount; i++)
{
printf("book name = %s", l[i].bk_name);
printf("\t author name = %s", l[i].author);
printf("\t pages = %d", l[i].pages);
printf("\t price = %f", l[i].price);
}
break;
case 3:
printf("Enter author name : ");
scanf("%s", ar_nm);
for (i = 0; i < keepcount; i++)
{
if (strcmp(ar_nm, l[i].author) == 0)
printf("%s %s %d %f", l[i].bk_name, l[i].author, l[i].pages,
l[i].price);
}
break;
case 4:
printf("Enter book name : ");
scanf("%s", bk_nm);
for (i = 0; i < keepcount; i++)
{
if (strcmp(bk_nm, l[i].bk_name) == 0)
printf("%s \t %s \t %d \t %f", l[i].bk_name, l[i].author,
l[i].pages, l[i].price);
}
break;
case 5:
printf("\n No of books in library : %d", keepcount);
break;
case 6:
printf("Made By:\n");
printf("Shourya Kole (RA2111028010015)\n");
break;
case 7:
exit(0);
}
}
return 0;
}