C++ How to Program (10th Edition)
C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
Question
Book Icon
Chapter 15, Problem 15.19E
Program Plan Intro

Push, pop and top operations of a stack.

Stack Container Adaptor uses sequential container to operate like a stack, which works as Last In First Out basis (LIFO).

push() - This will put a new element at top in stack.
pop() - Removes the element from the top of stack, without returning it.
top() - It will returns the top element of the stack, without deleting it from the stack.

Blurred answer
Students have asked these similar questions
What are the different operations that can be performed on a stack?
Machine organization The following operations are performed on a stack: PUSH A, PUSH B, POP, PUSH C, POP,POP,PUSH D, PUSH E, POP, PUSH F. What does the stack contain after each operation?
Knowledge of Stack Data Structure is a must. Create a stack data structure that can hold at most 10 items. Operations: Push, adds a new item on top of the stack. Pop, removes the item on top of the stack Top, returns the top item on top of the stack   To add item on top of the stack, enter PUSH followed by the value ex. PUSH 20   To remove the item on top of the stack, enter POP ex. POP   To print the value on top of the stack, enter TOP and it will print the top value and exit the loop. ex. TOP   Rest assured that the input will not generate IndexOutOfBoundsException Input 1. Operation e.g. PUSH 10, POP, TOP Description PUSH operation always comes first. Number of POP operations is equal to number of PUSH operations TOP will be the last. Sample PUSH·10 PUSH·20 POP TOP Output Enter·PUSH·N·to·add·value,·N·is·int·value Enter·POP·to·remove·value Enter·TOP·to·print·final·result: PUSH·10 PUSH·20 POP TOP 10
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning