-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_dequeue.c
More file actions
67 lines (65 loc) · 1.42 KB
/
test_dequeue.c
File metadata and controls
67 lines (65 loc) · 1.42 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
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include"dequeue.h"
int size;
int main()
{
int choice,operation,item;
printf("\nEnter the size of the queue: ");
scanf("%d",&size);
setsize(size);
do{
printf("\n\n1. Insert element\n2. Delete element\n3. Check if queue is empty\n4. Check if queue is full\n5. Exit\n\nEnter your choice: ");
scanf("%d",&operation);
if(operation==1)
{
printf("\nEnter element to insert: ");
scanf("%d",&item);
printf("\nWhere do you want to insert?\n1. Front\n2. Rear\n\nEnter you choice: ");
scanf("%d",&choice);
if(choice==1)
{
insert_front(item);
}
else if(choice==2)
{
insert_rear(item);
}
else
printf("\nInvalid choice!!\n");
}
else if(operation==2)
{
printf("\nWhere do you want to delete from?\n1. Front\n2. Rear\n\nEnter you choice: ");
scanf("%d",&choice);
if(choice==1)
delete_front(item);
else if(choice==2)
delete_rear(item);
else
{
printf("\nInvalid choice!!\n");
}
}
else if(operation==3)
{
if(isempty())
printf("Queue is empty\n");
else
printf("Queue is not empty\n");
}
else if(operation==4)
{
if(isfull(size))
printf("Queue is full\n");
else
printf("Queue is not full\n");
}
else if(operation==5)
exit(0);
else
printf("Enter a valid choice!");
}while(operation!=6);
return 0;
}