Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In class, you were given the source code for building a stack data structure. You are given this source code ( assign 5 . cpp

In class, you were given the source code for building a stack data structure. You are given this source code (assign5.cpp) but it misses the implementation of the "valueCheck" function. You are asked to provide the implementation of this function as described below.
The "valueCheck" receives the top pointer of a stack and updates the stack by removing all elements whose values are a multiple of 5. After that, the function returns top pointer of the stack after being modified.
Hints:
For implementing the "valueCheck" function, you should pop all values in the given stack into a temporary stack. While popping each value from the given stack, you can check if the value should be retained (i.e., not multiple of 5). After that, you can pop all values in the temporary stack and push them back to the original stack.
Example values that are multiple of 5 are 5,10,15,20, and 25. The value is a multiple of 5 if it divisible by 5 and the remainder of the division is 0.
The following screenshot shows the excepted output of code after providing the implementation of the "valueCheck" function.
7,15,18,5,2
7,18,2,
Import Notes:
You are NOT allowed to change the parameters and return value data type for the "valueCheck"function.
You must submit your code in a Text or CPP files (i.e.,*.txt or *.cpp). Other file formats (e.g.,
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions