stacks c++ code

Feb 9, 2010 at 11:13am
hello!! can you plzz give an example code, just a simple code for stacks ..
Feb 9, 2010 at 11:27am
what are stacks?
Feb 9, 2010 at 11:38am
queue and stacks sir!!
i have my queue code that`s why i`ll need stacks.. can you give some example code for stacks sir?
Feb 9, 2010 at 2:03pm
I think you need to explain yourself a bit clearer before anyone can help you..

What is the program you're trying to run? What is it designed to do?
Feb 9, 2010 at 4:02pm
If you have queue code then what's the problem??? It's much easier to program a stack as compared to queue.
Feb 9, 2010 at 5:35pm
just a simple code for stacks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
void push(int y)
{
         if(top>stackSize)
        {
                cout<<"stack full"<<endl;
                return;
        }
        else
       {
              top++;
              stack[top]=y;
        }
}
int pop()
{
         int a;
         if(top<=0)
         {
                cout<<"stack is empty"<<endl;
                return 0;
         }
         else
         {
                a=stack[top];
                top--;
          }
          return(a);
}
Topic archived. No new replies allowed.