-
Notifications
You must be signed in to change notification settings - Fork 179
Expand file tree
/
Copy pathQueue_C++.cpp
More file actions
58 lines (51 loc) · 1.1 KB
/
Copy pathQueue_C++.cpp
File metadata and controls
58 lines (51 loc) · 1.1 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
#include<iostream>
using namespace std;
int queue[100], n=100, front=-1, rear=-1,val,i;
void insert(){
if(rear==n-1){
cout<<"Queue Overflow\n";
}
else{
front=0;
cout<<"Enter the element \n";
cin>>val;
rear++;
queue[rear]=val;
}
}
void delet(){
if(front==-1 || front> rear){
cout<<"Queue Underflow \n";
}
else{
cout<<"Element deleted \n"<<queue[front]<<endl;
front++;
}
}
void display(){
if(front==-1 || front> rear){
cout<<"Queue is empty \n";
}
else{
cout<<"The elements inside the queue are: \n";
for(i=front; i<=rear; i++){
cout<<queue[i]<<endl;
}
}
}
int main(){
int ch;
do{
cout<<"Enter an the number of the operation to be performed \n 1. Insert \n 2. Delete \n 3. Display \n 4. Exit \n";
cin>>ch;
switch(ch){
case 1: insert();
break;
case 2: delet();
break;
case 3: display();
break;
default: cout<<"You have entered the wrong choice \n";
}
}while(ch!=4);
}