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
Add an array, which will store the most recent 5 recent transactions. For the array, add an insert function which will store the
Vika [28.1K]

The answer & explanation for this question is given in the attachment below.

Download docx
4 0
3 years ago
Who needs to be involved when assembling business solutions that include hardware and software?
sveta [45]
Software engineer i would say
5 0
3 years ago
Read 2 more answers
EDI stands for__________________ a) Electronic digital interface b) Electronic data interchange c) Enterprise data interface d)
vagabundo [1.1K]

The correct answer is B

6 0
4 years ago
What are the 3 parts of a browser window? What componets are in each?
Helga [31]
Here are the universal symbols: the minus symbol is minimize, the square(s) are for windowed mode, and the X symbol is for closing the browser. Branliest answer here.
7 0
4 years ago
A. which chip is thought to be the first microprocessor? how many transistors roughly did it use?
vaieri [72.5K]
A micro processor is an integrated circuit that have all the functions of a central processing unit of a computer.
The chip which is thought to be the first microprocessor is INTEL 4004. It was manufactured by Intel in 1971. Intel 4004 has 2,300 transistors. 
4 0
4 years ago
Other questions:
  • Which statement is true
    12·1 answer
  • Why should you use a named constant for the size of an array?
    9·1 answer
  • You are the project manger for Xylophone Phonics. It produces children's software programs that teach basic reading and math ski
    11·1 answer
  • Write and test the definition of a haskell function 'largest', which finds the largest element of a list, but is implemented usi
    15·1 answer
  • Which tool is best used to test an electrical current for a power source?
    8·1 answer
  • Write code to create a list of numbers from 0 to 67 and assign that list to the variable nums. Do not hard code the list. Save &
    5·1 answer
  • How long does it take to go 80 miles if you are going 80 mph?
    8·2 answers
  • For what reasons do readers use text-to-speech tools? Check all that apply.
    8·2 answers
  • Power point programm<br><br>​
    11·1 answer
  • PLEASE HELP<br><br><br> Write a pseudo code for an algorithm to wrap a gift.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!