Related questions with answers
Suppose that you have the following declaration:
stackType<double> stack(50);
double num;
and the input is
25 64 -3 6.25 36 -4.5 86 14 -12 9
Write a C++ code that processes this input as follows: If the number is nonnegative, it pushes the square root of the number onto the stack; otherwise it pushes the square of the number onto the stack. After processing these numbers write a C++ code that outputs the elements of the stack.
Solution
VerifiedWe're given a declaration and the input and we need to write code that will process the given input following the given instructions.
In the declaration, a stack was implemented as an array and a double
variable was declared.
The data type of elements in the stack is double
and it can hold 50 elements.
The given input is: 25 64 -3 6.25 36 -4.5 86 14 -12 9
Create an account to view solutions
Create an account to view solutions
More related questions
1/4
1/7