#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#define maxsize 3
void main()
{
clrscr();
int queue[maxsize],front=0,rear=0,i,choice,temp;
char ch;
do
{
cout<<"\n1 INSERT ";
cout<<"\n2 DELETE";
cout<<"\n3 DISPLAY";
cout<<"\n4 EXIT";
cout<<"\n\nEnter Your Choice: ";
cin>>choice;
switch(choice)
{
case 1:
{
if(rear==maxsize)
{
cout<<"\n\nQueue Overflow";
}
else
{
cout<<"\n\nEnter Element:";
cin>>temp;
queue[rear]=temp;
rear++;
}
break;
}
case 2:
{
if (front==rear)
{
cout<<"\n\nQueue Underflow";
}
else
{
cout<<"\n\nDeleted Element is: "<<queue[front];
front++;
}
break;
}
case 3:
{
if (front==rear)
{
cout<<"\n\nQueue Is Empty";
}
for(i=front;i<rear;i++)
{
cout<<"\n\nElement Of Stack:"<<queue[i];
}
break;
}
case 4:
{
{
exit(0);
}
break;
}
default:
cout<<"\n\nWrong Choise";
}
cout<<"\n\nDo You Want To Continue ? (press y/Y): ";
cin>>ch;
} while(ch=='Y'||ch=='y');
getch();
}
#include<conio.h>
#include<stdlib.h>
#define maxsize 3
void main()
{
clrscr();
int queue[maxsize],front=0,rear=0,i,choice,temp;
char ch;
do
{
cout<<"\n1 INSERT ";
cout<<"\n2 DELETE";
cout<<"\n3 DISPLAY";
cout<<"\n4 EXIT";
cout<<"\n\nEnter Your Choice: ";
cin>>choice;
switch(choice)
{
case 1:
{
if(rear==maxsize)
{
cout<<"\n\nQueue Overflow";
}
else
{
cout<<"\n\nEnter Element:";
cin>>temp;
queue[rear]=temp;
rear++;
}
break;
}
case 2:
{
if (front==rear)
{
cout<<"\n\nQueue Underflow";
}
else
{
cout<<"\n\nDeleted Element is: "<<queue[front];
front++;
}
break;
}
case 3:
{
if (front==rear)
{
cout<<"\n\nQueue Is Empty";
}
for(i=front;i<rear;i++)
{
cout<<"\n\nElement Of Stack:"<<queue[i];
}
break;
}
case 4:
{
{
exit(0);
}
break;
}
default:
cout<<"\n\nWrong Choise";
}
cout<<"\n\nDo You Want To Continue ? (press y/Y): ";
cin>>ch;
} while(ch=='Y'||ch=='y');
getch();
}
0 Comments