subject

Write the c++ implementation of following three member functions of the Stack class: getLength(): returns the number of elements in the stack
isEmpty(): returns true if the stack is empty, false otherwise
peek(): returns the value at the top of the stack without removing it. Assumes stack is not empty (no need to check)
The push function is given.

Write code in main to test these functions. Write a loop to enter an unknown number of positive integers. The loop stops when you enter 0 or a negative number. As you are entering integers, they are to be pushed onto a stack. Once done, display the number of elements on the first line and the value at the top of the stack on the next line.

Ex.: If the user enters '10 20 30 -1` the output should be:
3
30

Ex.: If the user enters '-1` the output should be:

0

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 20:30
1. for which of the following are you not required to signal beforehand? a. changing lanes b. speeding up c. stopping
Answers: 2
question
Computers and Technology, 23.06.2019 23:30
Perform an online search about the booting process of a computer and list all the steps
Answers: 2
question
Computers and Technology, 24.06.2019 13:30
In the rgb model, which color is formed by combining the constituent colors? a) black b) brown c) yellow d) white e) blue
Answers: 1
question
Computers and Technology, 24.06.2019 19:30
Which phrase is the best definition of a pivottable a a table containing data that is organized horizontally b a table used to calculate financial pivot values c a tool used to summarize data d a table containing specific formatting
Answers: 1
You know the right answer?
Write the c++ implementation of following three member functions of the Stack class: getLength(): r...
Questions
question
Computers and Technology, 10.06.2020 16:57
question
Physics, 10.06.2020 16:57