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
What are motion graphics?
AysviL [449]
D)Animated abstract shapes
3 0
2 years ago
What lets you do many things, like write book reports and stories?
Shalnov [3]

Answer:

4. application programs

Explanation:

5 0
3 years ago
Following the car in front of you at a closer distance _____.
tiny-mole [99]

Answer:

B. Doesn’t get you to your location faster.

Explanation:

Following the car in front of you at a closer distance doesn’t get you to your location faster.

6 0
3 years ago
Read 2 more answers
Design (draw a datapath) for a block that will help your processor decide whether to take a branch for different conditions. As
LekaFEV [45]

Answer:

See explaination

Explanation:

Here are the steps taken to draw the diagram!

opcode0 and the opcode1 signals are inverted/not to determine the case whether it is 00, 01, 10, 11.

Then they are 'and'ed with the corresponding Zero/lt signal to confirm if the case is true, for eg. zero = 1 if opcode = 00 (beq).

Then all the cases are 'or'ed to get the Branch signal!

See attachment for the diagram

8 0
3 years ago
What do I have to do to get you to cancel this subscription? I have emailed several times and every dang month I get a $10 charg
alexdok [17]
Contact the moderation team’s email
5 0
3 years ago
Other questions:
  • Marisol manages the online advertising campaigns for a chain of toy stores with both a physical and an online presence. Which Go
    7·1 answer
  • Consider the attack scenario given below:
    8·1 answer
  • Disk quotas are set using the ____ console. diskpart disk management mst windows explorer
    10·1 answer
  • Options to rotate cells in excel are available using the _____ button in the alignment group on the home tab.
    10·1 answer
  • There are many different types of decision-making. Which of the following is NOT a type of decision-making? a. fiat rule b. sing
    15·2 answers
  • Which two technologies support the building of single-page applications? and are two technologies helpful in building single pag
    12·1 answer
  • What is the meaning of 4 8 15 16 23 42?
    14·1 answer
  • I want to solve this question in C program, Please.
    7·1 answer
  • I get such an error when I turn on the computer, how can I fix it?
    7·1 answer
  • A type of attack where the adversary intercepts network packets, modifies them, and inserts them back into the network is called
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!