please see my code :
there are something wrong?how i can check if stack is empty??
NB : isi = content of stack
atas = top of stack
tumpukan is stack

function POP (var T : Tumpukan) : integer;
 begin
        POP := T.Isi[T.Atas];
        T.Atas := dec[T.Atas];
 end;

anyhelp will be appreciated..
thanks guys

please see my code :
there are something wrong?how i can check if stack is empty??
NB : isi = content of stack
atas = top of stack
tumpukan is stack

function POP (var T : Tumpukan) : integer;
 begin
        POP := T.Isi[T.Atas];
        T.Atas := dec[T.Atas];
 end;

i was modified your code and add a some code :
i use your initial code...

function POP (var T : Tumpukan) : integer;

 {*this function to check stack is empty or not*}
 function Empty(var T : Tumpukan): boolean;

 begin
   Empty := (T.Atas = 0)
 end;      

 begin
   if Empty(T) then
      POP := 0
   else
      begin
        POP := T.Isi[T.Atas];
        T.Atas := dec[T.Atas];
      end;
 end;

Ok. Hope this helps....

Comments
hei, i get this one too
helping much, thanks for empty function. you are really good guy with smart code :)

so i just to set the top of stack = 0 to build the empty function. thanks man. looks easy now.
Ok. see you again.:D

This question has already been answered. Start a new discussion instead.