You are on page 1of 6

=[u]= QUEUE.

CPP =7=[t1
include<iostream.h>
include<conio.h>
include <stdlib.h>
int q[1001,n, item:
int front=0;
i n t rear=0;
||void qs ize ()
cout<nEmitee the size of the gueue:";
cin>>n:
uoid addy (int item)

if (rear==n)
cout< ueue is Pul1:
else
i f CCfront==0) && (rear==0))

front=1:
1:28
F1 Help F2 Save F3 0pen Alt-F9 Compi le F9 Make F10 Menu
QUEUE.CPP -7=[tl
rear+=1:
[rearl=item:
Cout<< n h e ney ellenent is adlileil imto Bhe last nf the queule,"

oid deleteq()
int item=0:
if (front==0)
cout< nueue is empty."
else
{
item=q[front ]
if Cfront==rear)

front-0
rear-0

else
front =1:
41:28
F1 Help F2 Save F3 Open Alt-F9 Compile F9 Make F1O Menu
,

|Cout<<
QUEUE.CPP =7=[t11l
Cout<< ne e n e i l elenEmit is" <<item:

uoid displayq ()
Cout <nhe elenants im Bhe qLee
i f ((front==0) && (rear==0));
cout<nlhere is mp elenent im the ueue:
||for (int i=front: i<=rear: i+)
cout<<q[i1k< :

void main()

int item,ch
clrscrO:
cout<< L QUEUE
gsize():
cout&ntlenu:Sn 1.nddOsn2DeletelSn 3.DisplayO 4.1ilhn
62:28
F1 Help F2 Save F3 Open Alt-F9 Compile F9 Make F10 Menu
QUEUE.CPP =7=[

dof
cout<<Enter the chmice:";
cin>>ch:
switch(ch)
Case 1:
cout<< Emiter the elenent:"
cin>>item
addq Citem)
break
case 2:
deleteqO:
break:
case 3:
displayg )
break
case 4
exit (0)
break
def ault:
cout<<nError!!Enter the correct Choice.
83:28
F1 Help F2 Save F3 Open Alt-F9 Compile F9 Make F10 Menu
i l c Edit SCarch uln Compi lC Dcbug rojcct Uptlos Indow C p
QUEUE.CPP =7=[11
Coutk nl&nter the BlemenL
Cin>item;
addyitem)
break
case 2:
de lete();
|break:
case 3:
displayy 0:
break:
case 4:
exit (0)
break
def ault:
cout&nError!?Enter the correct choiee
break

whi le (ch?=4)

89:29
F1 Help F2 Save F3 Oven Alt-F9 Comoile F9 Make F10 Menu
JUEUT
Ehter the size of the queue:2
Menu:
1.AddQ
2.Delete
3.DisplayQ
4.Exit

Enter the choice:1

Enter the element:4

The new element is added into the last of the queue.


Enter the choice:2

The element is reoved fro the frot of the queue.


The removed eleent ist
Enter the choice :3

The elements in the queue :


There is no eleent in the queue:e
Enter the choice:

You might also like