-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathqueue.c
More file actions
59 lines (59 loc) · 848 Bytes
/
queue.c
File metadata and controls
59 lines (59 loc) · 848 Bytes
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
#include<stdio.h>
int queue[100];
int front=-1,rear=-1;
void insert(int n)
{
front=0;
if(front==0&&rear==sizeof(queue))
printf("Queue is full");
else
{
queue[rear]=n;
rear=rear+1;
}
}
int del()
{
int x;
if(front==-1)
printf("Queue is empty");
else
{
x=queue[front];
front=front+1;
}
return(x);
}
void display()
{
int i;
if(front!=-1)
for(i=front;i<=rear;i++)
printf("%d\t",queue[i]);
}
void main()
{
int c,x;
do
{
printf("\nMENU\n1.Insert\n2.Delete\n3.Display\n4.exit\nenter your choice:");
scanf("%d",&c);
switch(c)
{
case 1:
printf("Enter the number to be inserted:");
scanf("%d",&x);
insert(x);
break;
case 2:
printf("Deleted element:%d",del());
break;
case 3:
printf("Current status of queue:");
display();
break;
default:
break;
}
}while(c!=4);
}