1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Nonamiya [84]
3 years ago
7

Suppose that you have the following declaration:

Computers and Technology
1 answer:
masha68 [24]3 years ago
6 0

Answer:

Explanation:

The code is written in C++:

#include <iostream>

#include <stack>

#include <math.h>

#include <iomanip>

using namespace std;

/*

* Supporting method to print contents of a stack.

*/

void print(stack<double> &s)

{

if(s.empty())

{

cout << endl;

return;

}

double x= s.top();

s.pop();

print(s);

s.push(x);

cout << x << " ";

}

int main(){

// Declaration of the stack variable

stack<double> stack;

//rray with input values

double inputs[] = {25,64,-3,6.25,36,-4.5,86,14,-12,9};

/*

* For each element in the input, if it is positive push the square root into stack

* otherwise push the square into the stack

*/

for(int i=0;i<10;i++){

if(inputs[i]>=0){

stack.push(sqrt(inputs[i]));

}else{

stack.push(pow(inputs[i],2));

}

}

//Print thye content of the stack

print(stack);

}

OUTPUT:

5     8     9     2.5     6     20.25     9.27362     3.74166     144     3

-------------------------------------------------------------------------

Process exited after 0.01643 seconds with return value 0

Press any key to continue . . . -

You might be interested in
In a five-choice multiple-choice test, which letter is most often the correct
tatiyna

I believe the answer is C.

5 0
3 years ago
Read 2 more answers
Why is a Quality assurance tester needed on a software development team?
arsen [322]

Answer:

Quality assurance testing plays a very crucial role in the process of software development. It saves money and time by spotting bugs and errors early in the software development life-cycle. Software that is newly developed may have inconsistencies, redundancies, and flaws; therefore, proper QA testing is mandatory.

Explanation:

3 0
2 years ago
Marta is creating a program that will guide the user through a series of physical exercises. She wants the program to coach the
san4es73 [151]
She should use a condition-controlled loop. Because it uses a True/False and it will not continue until the task is done
7 0
2 years ago
Read 2 more answers
How to call a variable as a tag in react native.
Pepsi [2]

Explanation:

There is no need of adding template strings inside a <Text> component for adding strings in react-native. You can just use simple text and for variables, you can wrap it with curly braces

6 0
2 years ago
Create a program that has at least three classes. The class with main. A class that defines a Name (first name, middle name, and
Bond [772]

Answer:

See attached file for complete detailed code.

Explanation:

See attached file.

Download txt
3 0
3 years ago
Other questions:
  • Which of these is outside the scope of an art director's responsibility?
    12·2 answers
  • How does microchip work
    12·1 answer
  • Which of the following TCP/IP settings should be configured to specify DNS suffixes to use other than resolving names through a
    9·1 answer
  • What do you think was the immediate effect of the introduction of handheld consoles and video games?
    6·1 answer
  • What is a scholary or systemic investigation or injury about a subject?
    14·1 answer
  • In an array-based implementation of a dictionary, if you represent the entries as an array of objects that encapsulate each sear
    12·1 answer
  • Why would a programmer use a flow chart? (Edge2020 Coding Critical Thinking Questions)
    9·1 answer
  • Why do certain words change color in Python?
    6·1 answer
  • You do not have to move your fingers to click the top row reach keys.<br> 1. True <br> 2. False
    15·1 answer
  • Which device is used to direct the flow of data on a computer network?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!