-
Notifications
You must be signed in to change notification settings - Fork 0
/
Library_Entry&Exit_Log.c
62 lines (51 loc) · 1.58 KB
/
Library_Entry&Exit_Log.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
//C program to find in person count, out person count and available person in a library
#include <stdio.h>
int Enter_Library(int n,int g,int h)
{
switch(n)
{
case 1:
g++;
printf("\nOne person entered the library. Total people inside: %d",g-h);
return g;
case 2:
return g;
case 3:
printf("\nTotal people entered: %d\nTotal people exited: %d\nAvailable people in the library: %d",g,h,g-h);
break;
}
}
int Exit_Library(int n,int g,int h)
{
switch(n)
{
case 1:
return h;
case 2:
h++;
printf("\nOne person exited the library. Total people inside: %d",g-h);
return h;
case 3:
break;
}
}
int main()
{
int x,In_Count_Person=0,Out_Count_Person=0;
printf("\nSelect an option:\n1. Enter the library\n2. Exit the library\n3. Display count of people\n4. Exit the program\nEnter your choice: ");
scanf("%d",&x);
if (x>0,x<=4) //Checking boundary condition
{
while (x!=4, x>0, x<4)
{
{
In_Count_Person=Enter_Library(x,In_Count_Person,Out_Count_Person);
Out_Count_Person=Exit_Library(x,In_Count_Person,Out_Count_Person);
printf("\nSelect an option:\n1. Enter the library\n2. Exit the library\n3. Display count of people\n4. Exit the program\nEnter your choice: ");
scanf("%d",&x);
}
}
printf("Exiting");
}
return 0;
}