Sunday, 5 October 2014

DELETION IN QUEUE

/*Deletion in queue*/
#include<iostream.h>
#include<conio.h>                 /*for clrscr hedder file*/
#include<stdlib.h>
void main()
{
clrscr();
int queue[]={1,2,3,4,5,6,7,8},rear=7,front=-1;  /*variable initiation*/
char choice;
do
{
if(front==-1&&rear==-1)
 { cout<<"\n underflow";
exit(0);
}
if(front==rear)
{          front=rear=-1;

 }
else
{    front=front+1;
cout<<"\n\n Elememt deleted...";
cout<<queue[front];
cout<<"\n\n Queue..................\n";
for(choice=rear;choice>=front;choice--)
cout<<queue[choice]<<endl;
}


cout<<"\n\n\nDo u want to continue press 1 ";
cout<<"\nEnter your choice ";
cin>>choice;
}while(choice=='1');
}

2 comments: