Hi everybody;
I just started to learn stacks. How can I count the number of Items in a stack by using ADT stack operations?? Can u help me?

What operations do you have available? If you can only use push, pop, and empty then you're stuck with removing every item until the stack is empty and counting them. Any decent stack implementation will provide you with some form of size operation that will tell you how many items there are, so you need to be more specific.

empty auxiliary stacks are available.

>empty auxiliary stacks are available.
Getting information out of you people is like pulling teeth. Did you know that? I'll assume that you can only use push, pop, and empty. In that case, pop every item in the stack, increment a counter and push that item onto a second stack. When the first stack is empty, do the reverse but don't increment the counter and you'll have the same stack that you started with.

Write your own ADT that uses a stack and keeps a count of how many elements are in the stack.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.