Created
October 2, 2016 05:49
-
-
Save rashedcs/61edccaee3de144d766ddec621ad45f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<stdlib.h> | |
using namespace std; | |
int front=0,rear=0; | |
void insertion(int queue[]) | |
{ | |
int num; | |
cout<<"\nEnter the item to be inserted : "; | |
cin>>num; | |
if(rear==100) | |
{ | |
cout<<"\nQueue OverFlow Occured\n"; | |
// front=rear=0; | |
} | |
else | |
{ | |
queue[rear++]=num; | |
cout<<"Succesful Inserted "<<endl; | |
} | |
} | |
void deletion(int queue[]) | |
{ | |
int element; | |
if(front==rear) | |
{ | |
cout<<"The queue is empty "<<endl; | |
} | |
else | |
{ | |
cout<<"\nThe deleted element is : "<<queue[front++]; | |
} | |
} | |
void display(int queue[]) | |
{ | |
if(front==rear) | |
{ | |
cout<<"\nThis queue is empty \n"; | |
} | |
else | |
{ | |
for(int i=front; i<rear; i++) | |
{ | |
cout<<queue[i]<<" "; | |
} | |
} | |
} | |
int main() | |
{ | |
int queue[100]; | |
int option; | |
while(1) | |
{ | |
cout<<"\n\n"; | |
cout<<"\n1.Insert an element"; | |
cout<<"\n2.Delete an element"; | |
cout<<"\n3.Display queue"; | |
cout<<"\n4.Exit"; | |
cout<<"\n\nEnter your choice : "; | |
cin>>option; | |
if(option==1) insertion(queue); | |
else if(option==2) deletion(queue); | |
else if (option==3) display(queue); | |
else if(option==4) exit(0); | |
else cout<<"Sorry Sir , Wrong Choice "<<endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment