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 01:30
What “old fashioned” features of checking accounts is p2p replacing
Answers: 3
question
Computers and Technology, 22.06.2019 08:30
Today is the anniversary of me being on yet, i don't need it anymore! here's a picture of my dog wearing a bowtie! my question is, how do i delete my account?
Answers: 1
question
Computers and Technology, 23.06.2019 19:30
Anul 2017 tocmai s-a încheiat, suntem trişti deoarece era număr prim, însă avem şi o veste bună, anul 2018 este produs de două numere prime, 2 şi 1009. dorel, un adevărat colecţionar de numere prime, şi-a pus întrebarea: “câte numere dintr-un interval [a,b] se pot scrie ca produs de două numere prime? “.
Answers: 1
question
Computers and Technology, 24.06.2019 22:00
Is the process of organizing data to reduce redundancy. a. normalization b. primary keying c. specifying relationships d. duplication
Answers: 1
You know the right answer?
Write the c++ implementation of following three member functions of the Stack class: getLength(): r...
Questions
question
Social Studies, 13.01.2020 10:31
Questions on the website: 13722360