-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathqueue_linear.c
More file actions
79 lines (74 loc) · 1.26 KB
/
queue_linear.c
File metadata and controls
79 lines (74 loc) · 1.26 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
// [implementation linear queue using array]
/*
#include <stdio.h>
#define maxsize 5
int Q[maxsize];
int F = -1, R = -1;
void enQ()
{
int value;
if (R == (maxsize-1))
printf("Overflow.\n");
else
{
if ((F == -1) && (R == -1))
{
F = 0;
R = 0;
}
else
R++;
}
printf("Enter value to be inserted:\n");
scanf("%d",&value);
Q[R] = value;
}
void deQ()
{
if (F == -1)
printf("Underflow.\n");
else
{
printf("%d is deleted.\n",Q[F]);
if (F == R)
{
F = -1;
R = -1;
}
else
F++;
}
}
void display()
{
int i;
if (F == -1)
printf("Q is empty.\n");
else
{
for (i = F; i <= R; ++i)
printf("%d\n",Q[i]);
}
}
void main()
{
int c,value;
while (1)
{
printf("Enter your choice:\n1-Insert\n2-Delete\n3-Display\n4-Quit\n");
scanf(" %d",&c);
switch (c)
{
case 1:enQ();
break;
case 2:deQ();
break;
case 3:display();
break;
case 4:
return;
default:printf("Wrong choice.\n");
}
}
}
*/