-
Notifications
You must be signed in to change notification settings - Fork 2
/
eight8.c
77 lines (64 loc) · 1.11 KB
/
eight8.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
#include <stdio.h>
int arr[2];//declaring an array
int rear=-1,front=0;
int main()
{
int ele,select;
printf("Enter 1 for check if it is empty\nEnter 2 for check if it is full\n");
printf("Enter 3 for Enqueue\nEnter 2 for dequeue\nEnter : ");
scanf("%d",&select);
switch (select)
{
case 1:
isempty();
break;
case 2:
isfull();
break;
case 3:
printf("Enter Element : ");
scanf("%d",&ele);
enqueue(ele);
main();
break;
case 4:
dequeue();
break;
default:
printf("Invalid Input");
}
}
void isempty(void)
{
if (rear==-1)
{
printf("Queue is Empty");
}
else
{
printf("Queue is Not Empty");
}
}
void isfull(void)
{
if(rear==2)
{
printf("Queue is Full");
}
else
{
printf("Queue is not Full");
}
}
void enqueue(int ele)
{
rear++;
arr[rear]=ele;
}
int dequeue()
{
int item;
item = arr[front];
front++;
return item;
}