Answers for "stack cpp code example"

C++
0

simplest code for stack implementation in c++

void push(int val) {
   if(top>=n-1)
   cout<<"Stack Overflow"<<endl;
   else {
      top++;
      stack[top]=val;
   }
}
Posted by: Guest on November-01-2021
0

simplest code for stack implementation in c++

void display() {
   if(top>=0) {
      cout<<"Stack elements are:";
      for(int i=top; i>=0; i--)
      cout<<stack[i]<<" ";
      cout<<endl;
   }else
   cout<<"Stack is empty";
}
Posted by: Guest on November-01-2021

Browse Popular Code Answers by Language