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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 23:30, sheram2010
Acomputer is a multipurpose device that accepts input, processes data, stores data, and produces output, all according to a series of stored . the processing unit of most modern computers is a(n) . the instructions that tell a computer how to carry out a task are referred to as computer , which are distributed as software. computers run three main types of software: software, system software, and development tools. an example of system software is a computer system, which is essentially the master controller for all the activities that a digital device performs. digital devices are constructed using tiny electronic components that represent data bits as electrical signals. the system unit houses the system board, which contains several circuits made from semiconducting materials. computers come in three popular form factors: component, , and slate. many of today's digital devices operate on battery power supplied by ion batteries. battery life and lifespan can be extended by following good battery management practices.
Answers: 3
image
Computers and Technology, 22.06.2019 01:30, chastineondre7979
How will you cite information that is common knowledge in your research paper?
Answers: 1
image
Computers and Technology, 22.06.2019 04:30, kkeith121p6ujlt
Eye injuries usually occur as a result of all of the following things, except: a) proper machine operation b) battery explosion c) falling or flying debris d) electric welding arc
Answers: 2
image
Computers and Technology, 22.06.2019 20:00, hannahliebl2000
Need asap write a short paper describing the history and differences between six sigma, waterfall, agile, and scrum models. understanding these models can give you a good idea of how diverse and interesting it development projects can be. describe what the rationale for them is and describe their key features. describe the history behind their development. at least 400 words
Answers: 1
You know the right answer?
Write the c++ implementation of following three member functions of the Stack class: getLength(): r...

Questions in other subjects: