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]
2 years ago
7

Suppose that you have the following declaration:

Computers and Technology
1 answer:
masha68 [24]2 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
25 points select 3 options!!!!!!!!!!!!!!!!!!!!!!!!!
STALIN [3.7K]
A, B , and E sorry if I’m wrong
4 0
2 years ago
Which part of a computer is responsible for executing the software programs?
mamaluj [8]

Answer:

c. CPU

Explanation:

7 0
3 years ago
A grade of B is worth Grade points<br><br><br> A) 3.0<br> B) 80<br> C)2.0<br> D)4.0
Elodia [21]

Answer:

I am pretty sure. In my view answer is 4.0

8 0
3 years ago
Read 2 more answers
Media has scientifically been linked to media messages, as in the cause and effect theory. True or False?
padilas [110]

Answer:

true

this ans is not 100% correct but it may help you

4 0
3 years ago
What is true about an electric field around a negative charge?
FrozenT [24]

The electric field points outward

8 0
3 years ago
Read 2 more answers
Other questions:
  • What do you call the combination of title, description, tags, and thumbnail?
    6·1 answer
  • What is the basic purpose of Google calendar?
    14·2 answers
  • Before sharing a document, you must first save the document to
    12·1 answer
  • Oxygen-18 has an atomic number of 8. How many neutrons are in this isotope?
    7·1 answer
  • Communication is the transmission of messages to large audiences.
    14·1 answer
  • GIVING BRAINLIST TO WHOEVER ANSWERS
    9·1 answer
  • What is the purpose of using variables in programming?
    11·1 answer
  • Raul is a 13-year-old teenager interested in taking up photography as a new hobby. His dad wants to buy him a camera for his bir
    13·1 answer
  • Why is it better for a CPU to have more than one cache?
    6·2 answers
  • 12. Your project specifications call for a business rule that the database design can't
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!