Home   Easy-Code    Forum  Updater 
Twitter Facebook



Program using stacks using pascal

Critics Rating:

Users Rating:

(*PROGRAM USING STACKS*)

program stack;

uses crt;

var

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

item,top,cho,i:integer;

n,ch:char;

procedure push;

begin

clrscr;

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

read(item);

if top=5 then

begin

writeln(" STACK IS FULL ");

exit;

end

else

top:=top+1;

st[top]:=item;

for i:=top downto 1 do

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

end;

procedure pop;

begin

clrscr;

begin

if top=0 then

begin

writeln("STACK IS EMPTY ");

exit;

end

else

item:=st[top];

top:=top-1;

end;

writeln("THE TOP NUMBER DELETED FORM THE STACK IS ",item);

for i:=top downto 1 do

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

end;

begin {* MAIN *}

clrscr;

top:=0;

repeat

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.