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, 22.06.2019 00:20
What’s resistance in an electrical circuit ?
Answers: 1
question
Computers and Technology, 22.06.2019 21:00
Kirk found a local community college with a two-year program and he is comparing the cost with that of an out-of-state two-year school. what is the expected total cost for one year at the local community college if kirk lives at home? what is the expected total cost for one year at the out-of-state school if kirk lives on campus?
Answers: 2
question
Computers and Technology, 23.06.2019 12:00
From excel to powerpoint, you can copy and paste a. cell ranges and charts, one at a time. b. cell ranges and charts, simultaneously. c. charts only. d. cell ranges only.
Answers: 3
question
Computers and Technology, 24.06.2019 06:00
Hey i really need some solving this problem: 1. encrypt this binary string into cipher text: 110000. include in your answer the formula the decoder would use to decrypt your cipher text in the format (coded answer) x n mod (m) = y & 2. decrypt this cipher text into a binary string: 106 you.
Answers: 2
You know the right answer?
Write the c++ implementation of following three member functions of the Stack class: getLength(): r...
Questions
question
Mathematics, 25.02.2022 08:00
question
Mathematics, 25.02.2022 08:00
question
Mathematics, 25.02.2022 08:00
question
Mathematics, 25.02.2022 08:00
question
Mathematics, 25.02.2022 08:00
Questions on the website: 13722367