-
Notifications
You must be signed in to change notification settings - Fork 0
/
queue.c
80 lines (74 loc) · 1.2 KB
/
queue.c
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
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#define SIZE 10
void insert();
void delete();
void display();
int f = -1,r = -1;
char queue[SIZE],data;
void main()
{
int choice;
while(1)
{
printf("\n*************************** WELCOME TO QUEQE **********************\n \n 1. INSERT \n 2. DELETE \n 3. DISPLAY \n 4. QUIT \n\n Enter Your choice :: " );
scanf("%d",&choice);
switch(choice)
{
case 1 : insert();
break;
case 2 : delete();
break;
case 3 :display();
break;
case 4 :exit(0);
default : printf("INVALID input");
}
}
}
void insert()
{
printf("\t\t\t INSERT");
if(r==SIZE - 1)
{
printf("\n Queue is full\n");
return;
}
printf("\n INPUT::");
scanf("%c",&data);
if(r==-1)
{
f=0;
r=0;
}
else
{
r=r+1;
}
queue[r]=data;
printf("%c is inserted",data);
}
void delete()
{
printf("\t\t\t DELETING...............\n");
if(f=-1)
{
printf("\nQUEUE IS EMPTY");
return;
}
data=queue[f];
if(f=r)
{
r=-1;
f=-1;
}
else
{
f=f+1;
}
printf("\n %c is deleted",data);
}
void display()
{
}