-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathQueue using array
More file actions
72 lines (72 loc) · 1.03 KB
/
Queue using array
File metadata and controls
72 lines (72 loc) · 1.03 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
#include <stdio.h>
int main()
{
int A[10],ele,i,F=-1,R=F,ch;
do
{
printf("Enter your choice\n");
printf("Press 1 for insertion\nPress 2 for deletion\nPress 3 for display\nPress 4 gor quit\n");
scanf("%d",&ch);
if(ch==1) //insertion
{
if(R==9)
{
printf("Insertion is not possible\n");
}
else
{
if(F==-1 && R==-1)
{
F=0;
R=0;
printf("Enter the element\n");
scanf("%d",&ele);
A[R]=ele;
}
else
{
R++;
printf("Enter the element\n");
scanf("%d",&ele);
A[R]=ele;
}
}
}
else if(ch==2) //deletion
{
if(F>R)
{
printf("Deletion is not possible\n");
}
else
{
printf("%d is deleted\n",A[F]);
F++;
}
}
else if(ch==3) //display
{
if(F>R)
{
printf("No element in Queue\n");
}
else
{
for(i=F;i<=R;i++)
{
printf("%d\t",A[i]);
}
printf("\n");
}
}
else if(ch==4) //quit
{
exit(0);
}
else
{
printf("Wrong choice\n");
}
}while(ch!=4);
return 0;
}