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
When the binary code is retrieved from ram and moved to the cpu, this stage is known as
vaieri [72.5K]

This stage is known as fetching.

  • Any operation you do in a computer, it runs a lot of codes inside it, and these codes are in binary.
  • For the operation, the computer accesses the RAM memory to gather information about this process, and moves it to the CPU, in a process named as fetching.
  • Thus, the stage asked in this problem is known as fetching.

A similar problem is given at brainly.com/question/21536104

4 0
2 years ago
Code Problem 3 in Python 2.
11111nata11111 [884]

I've included my code in a picture below. I hope this helps.

7 0
3 years ago
A diagram of a ten-node network that uses ten routers
tiny-mole [99]

The diagram of the of a ten-node network that uses ten routers is given in the image attached.

<h3>What is a node in a network?</h3>

A network node is known to be be seen as the kind of connection point that is seen amidst some network devices such as routers, printers, etc.

Note that they are known to often receive and send data from one network or endpoint to another.

Therefore, The diagram of the of a ten-node network that uses ten routers is given in the image attached.

Learn more about routers from

brainly.com/question/24812743

#SPJ1

3 0
2 years ago
There are many careers within the IT industry. _____ are responsible for organizing a company's data, making sure all the data i
devlian [24]
C. database administrators are responsible for organizing a company's data making sure all the data is accurate' available' and secure
5 0
3 years ago
What is the value of |-10|
Goshia [24]
Its 10, value always has to be positive.
6 0
3 years ago
Other questions:
  • Explain what a dam is and what it does
    12·1 answer
  • What is one way to process your thoughts about the information you are reading?
    14·2 answers
  • A ____ is a type of program that uses a grid to organize and work with data.
    14·1 answer
  • What is a step by step procedure written to carry out a task?
    11·1 answer
  • The network layer of the Internet model uses the _____________ protocol to route messages though the network.
    13·1 answer
  • Which type of computer graphic can be blown up to a much larger size without getting distorted or losing quality?
    5·1 answer
  • The ______ printers are the most popular type of printer in small office/home office and large office environments.
    5·1 answer
  • Hello i need help whats -5 = 500
    13·2 answers
  • Identifying correction services tasks
    14·2 answers
  • What is the basic body structure of html.
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!