-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqusingarr.c
More file actions
59 lines (54 loc) · 1.11 KB
/
qusingarr.c
File metadata and controls
59 lines (54 loc) · 1.11 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
#include<stdio.h>
#define max 20
int arr[max], top = 0 , rear = -1;
void Add(){
rear++;
if(rear == max){
printf("Queue is Full");
rear--;
}
else{
printf("Enter Element:");
scanf("%d",&arr[rear]);
}
}
void Remove(){
if(top==max-1){
printf("Queue is Empty");
}
else{
printf("Pop element is : %d\n",arr[top]);
top++;
}
}
void Display(){
if(top==rear) printf("Queue is empty");
else{
for(int i=top;i<=rear;i++){
printf("%d ",arr[i]);
}
printf("\n");
}
}
int main(){
printf("Enter Option:\n");
printf("1.Add\n2.Remove\n3.Display\n4.Exit\n");
int f;
while(1){
printf("Enter Choice:");
scanf("%d",&f);
switch(f){
case 1:
Add();
break;
case 2:
Remove();
break;
case 3:
Display();
break;
case 4:
return 0;
}
}
}