Home   Easy-Code    Forum  Updater 
Twitter Facebook



Program for queues using pascal

Critics Rating:

Users Rating:

(*PROGRAM FOR QUEUES*)

program queue;

uses crt;

var

Q:Array[1..10] of integer;

i,cho,item,rear,front:integer;

procedure push;

begin

clrscr;

writeln("ENTER THE NUMBER TO BE INSERTED ");

read(item);

if rear=5 then

begin

writeln(" QUEUE IS FULL ");

front:=0;

end

else

begin

rear:=rear+1;

Q[rear]:=item;

end;

for i:=front+1 to rear do

writeln(" | ",q[i]," | ");

end;

procedure pop;

begin

clrscr;

begin

if front=rear then

begin

writeln("QUEUE IS EMPTY ");

rear:=0;

end

else

begin

front:=front+1;

item:=Q[front];

end;

end;

writeln("THE DELETED ELEMENT IS ",item);

for i:=front+1 to rear do

writeln("| ",q[i]," |");

end;

begin {* MAIN *}

clrscr;

front:=0;

rear:=0;

repeat

writeln;

writeln("1.INSETION ");

writeln("2.DELETION ");

writeln("3.EXIT ");

writeln("ENTER YOUR CHOICE ");

read(cho);

case cho of

1:push;

2:pop;

3:exit;

end;

until cho=3;

end.

Courtesy, Source, References & Regards: Kishore AVGK

While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright@2009-2011 by KuGuNi.com. All Rights Reserved.