-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path28_CircularQueue_Using_Array.c
More file actions
148 lines (137 loc) · 2.96 KB
/
28_CircularQueue_Using_Array.c
File metadata and controls
148 lines (137 loc) · 2.96 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
28
Circular Queue using array
Name: Sayooj K
Roll no: 45
*/
#include<stdio.h>
#include<string.h>
void main()
{
int arr[11],f,l,i,ele,temp,choice;
f=0;
l=0;
do
{
printf("\nMENU\n1.Insertion\n2.Deletion\n3.Dispaly\n4.Exit\nEnter choice: ");
scanf("%d",&choice);
switch(choice)
{
case 1: if(l==0)
{
printf("Enter element: ");
scanf("%d",&ele);
f=1;
l=1;
arr[l]=ele;
}
else if(f==(l+1))
{
printf("\nQueue is FULL\n");
}
else
{
temp=l;
temp=((temp%10)+1);
if(temp!=f)
{
l=temp;
printf("Enter element: ");
scanf("%d",&ele);
arr[l]=ele;
}
else
{
printf("\nQueue is FULL\n");
}
}
break;
case 2: if(f==0)
{
printf("\nQueue is EMPTY\n");
}
else
{
if(f==l)
{
f=0;
l=0;
}
else
{
f=((f%10)+1);
}
}
break;
case 3: i=f;
while(i!=(l+1))
{
if(l==10 && i==10)
{
printf(" %d <-",arr[i]);
break;
}
printf(" %d <-",arr[i]);
i=((i%10)+1);
}
break;
}
}while(choice==1 || choice==2 || choice==3);
}
/*
OUTPUT:
MENU
1.Insertion
2.Deletion
3.Dispaly
4.Exit
Enter choice: 1
Enter element: 43
MENU
1.Insertion
2.Deletion
3.Dispaly
4.Exit
Enter choice: 1
Enter element: 87
MENU
1.Insertion
2.Deletion
3.Dispaly
4.Exit
Enter choice: 3
43 <- 87 <-
MENU
1.Insertion
2.Deletion
3.Dispaly
4.Exit
Enter choice: 1
Enter element: 11
MENU
1.Insertion
2.Deletion
3.Dispaly
4.Exit
Enter choice: 3
43 <- 87 <- 11 <-
MENU
1.Insertion
2.Deletion
3.Dispaly
4.Exit
Enter choice: 2
MENU
1.Insertion
2.Deletion
3.Dispaly
4.Exit
Enter choice: 3
87 <- 11 <-
MENU
1.Insertion
2.Deletion
3.Dispaly
4.Exit
Enter choice: 4
*/