-
Notifications
You must be signed in to change notification settings - Fork 237
/
queue
66 lines (56 loc) · 926 Bytes
/
queue
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
/*funtion of queue*/
#include <stdio.h>
int max=50 ,front = -1, rear = -1, queue[50];
void enQueue(int val){
if(rear==max-1){
printf("overflow");
return;
}
else{
if(front ==-1)
front=0;
queue[++rear]=val;
}
}
void deQueue(){
int val;
if(front == -1){
printf("Underflow");
return;
}
else{
val=queue[front++];
}
}
void peep(){
if(rear==-1)
return;
else{
int t=queue[front];
printf("\nPeep : %d\n", t);
}
}
void display(){
if(rear==-1)
return;
else{
int i;
printf("Queue are: \n");
for (i = front; i <= rear; i++)
printf("%d ", queue[i]);
}
}
int main()
{
enQueue(10);
enQueue(2);
enQueue(25);
enQueue(30);
enQueue(4);
deQueue();
deQueue();
enQueue(500);
peep();
display();
return 0;
}