Suppose that you have the following declaration:
stack Type stack(50); double num; and the input is
25 64-3 6.25 36-4.5 86 14 -129
Write a C++ code that processes this input as follows: If the number is non-negative, it pushes the square root of the number onto the stack; otherwise it pushes the square of the number onto the stack. After processing these numbers write a C++ code that outputs the elements of the stack.

Answers

Answer 1

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 . . . -


Related Questions

Which of the following examples requires a citation in a paper you're writing?
A. General information you already knew but want to clarify or conform
B. The table of contents
C. A paraphrasing of your original work in a different section of your paper
D. A direct quotation that is marked off by quotation marks

Answers

Answer:

D. A direct quotation that is marked off by quotation marks

Explanation:

Quotation marks are responsible for indicating that some texts are explicitly referenced in a paper with no changes made. This type of quote must be very well referenced in the paper, both on lines where the quotes are written with author's surname, date of publishing, page referenced, and also on the bibliography at the end of the paper with all these references very well detailed, including text's title, translators (if any), number of editions, publishing house, and more. It is important to highlight it depends on the policies of publishing the paper must follow because there are different patterns for referencing and quoting.

PLS I WILL GIVE BRAINLIEST IF CORRECT

Select the correct answer.

Stacy is in the process of creating a storyboard for her personal website, but she is unable to decide which storyboarding technique to use. Which technique would work best for her?


A. hierarchical
B. linear
C. webbed
D. wheel

Answers

Answer:webbed

Explanation:

k

Answer:

Webbed

Explanation:

What problem can enabling compression present when you are using ssh to run remote X applications on a local display?

Answers

Answer:

Compression over ssh connection would increase network latency, using most of its bandwidth to crippling network efficiency.

Explanation:

SSH is a protocol in computer networking used by administrators to manage a remote network. Various commands are run remotely with this connection. The compression command is enabled in the remote network with the -C option in the ssh configuration. Compression over ssh is only favorable over low bandwidth networks.

Which is the best video game antagonist?

A. Link
B. Cloud Strife
C. Mario
D. The Dragonborn

Answers

Answer:

mario Martinez was making a use of the surge how he might help him out side

Mario.

Link, I need more letters so I am doing this

Which vulnerability can occur if a programmer does not properly validate user input and allows an attacker to include unintended SQL input that can be passed to a database?

Answers

Answer:

SQL injection

Explanation:

SQL injection is a vulnerability in databases that occurs when user input is not properly validated. Hackers are able to input SQL query statements to bypass the use of the actual user name and password to gain access to the account.

Using placeholders in programmed SQL statements mitigates the effects of SQL injection.

Prompt
Using complete sentences post a detailed response to the following.
Have you ever tried to learn a new language or do you have friends who've had that experience? What are some of the
steps you would take to learn a new language, and what are some challenges that might arise? What are some things that
can help make the process easier?

Answers

Have you ever tried to learn a new language or do you have friends who've had that experience?

Yes, I tried to learn Python and I even managed to do two Discord bots which are (somewhat) functional, but I'm far to say that I've managed to lean the language completly. There are lots of things to learn on a language as Python.

I also leant PHP on my own and managed to do a website (somehow) functional.

What are some of the  steps you would take to learn a new language, and what are some challenges that might arise?

The first steps in learning any computer language is learning the syntax. If you manage to do that, with the experience you gained from previous projects/languages you might be able to create something working. At times you might feel down if the project doesn't work as expected.

What are some things that  can help make the process easier?

Video tutorials, experiments and searching questions and problems on Google is a very important resource.

write c++ program from 1to 100 to find prime numbers using statement.​​

Answers

#include <iostream> using namespace std; int isPrimeNumber(int); int main() { bool isPrime; for(int n = 2; n < 100; n++) { // isPrime will be true for prime numbers isPrime = isPrimeNumber(n); if(isPrime == true) cout<<n<<" "; } return 0; } // Function that checks whether n is prime or not int isPrimeNumber(int n) { bool isPrime = true; for(int i = 2; i <= n/2; i++) { if (n%i == 0) { isPrime = false; break; } } return isPrime; }

Lynn would like to insert a hyperlink into an email message without using the ribbon. What is the keyboard shortcut to do so?

Ctrl+G
Ctrl+K
Ctrl+C
Ctrl+Shift+G

Answers

Answer:

Ctrl+K

Explanation:

Edg 2020

B on edg 2021, hope i could help

Assume a file containing a series of integers is named numbers.txt and exists on the computer’s disk. Write a program that reads all of the numbers stored in the file, calculates their total and displays it.


Very Important: The file could have any number of numbers, so you need to use a loop to process the data in the file

Answers

#include <iostream>

#include <fstream>

using namespace std;

int main(){

   int x, sum=0;

ifstream f("numbers.txt");

while(!f.eof()){

       f >> x;

       sum +=x;

}

cout << "Sum : " << sum;

}

This is a C++ program.

Next time be more precise on the programming language you want

Write a program that removes all the occurrences of a specified string from a text file. Your program should prompt the user to enter a filename and a string to be removed.

Answers

Answer:

filename = input("Enter file name: ")

rm_word = input("Enter word to remove from file: ")

with open(filename, "r") as file:

   mytext = file.read().strip()

   replace_word = mytext.replace(rm_word, "")

   print(replace_word)

Explanation:

The python program prompt user for the file name and the string word to remove from the text. The file is opened with the 'with' keyword and the file content is read as a string and stripped of white space at the beginning and end of the string. The string's 'replace' method is used to remove the target word.

how to create use an array of Course objects instead of individual objects like course 1, course 2, etc

Answers

Answer:

To save the course object instances in an array, use;

Course[] courses = new Course[7];

courses[0] = new Course("IT 145");

courses[1] = new Course("IT 200");

courses[2] = new Course("IT 201");

courses[3] = new Course("IT 270");

courses[4] = new Course("IT 315");

courses[5] = new Course("IT 328");

courses[6] = new Course("IT 330");

Explanation:

The java statement above assigns an array of size 7 with the course class constructor, then order courses are assigned to the respective indexes of the new array.

Asymmetric encryption uses only 1 key.

A)
False

B)
True

Answers

A.) false

Symmetric encryption uses a single key that needs to be shared among the people who need to receive the message while asymmetric encryption uses a pair of public key and a private key to encrypt and decrypt messages when communicating.
A) false is the answer

hello hello . please help me​

Answers

Answer:

#include <iostream>  

using namespace std;  

int main()  {  

 int num, check=0;  

 for(int num = 1; num<=100;num++){

for(int i = 2; i <= num/2; i++)  {

     if(num % i == 0)   {  

         check=1;  

         break;         }     }  

 if (check==0)  {       cout <<num<<" ";     }

 check = 0;

 }

 return 0;  

}

Explanation:

This line declares num as integer which represents digits 1 to 100.

A check variable is declared as integer and initialized to 0

 int num, m=0, check=0;  

This for loop iterates from 1 to 100

 for(int num = 1; num<=100;num++){

This iterates from 2 to half of current digit

for(int i = 2; i <= num/2; i++)  {

This checks for possible divisors

     if(num % i == 0)   {  

If found, the check variable is updated to 1

         check=1;  

And the loop is terminated

         break;         }     }  

The following if statement prints the prime numbers

 if (check==0)  {       cout <<num<<" ";     }

 check = 0;

 }

Which tools can Object Drawing Mode be applied to?
Line tool
Rectangle Tool
Oval Tool
Pencil tool
Pen Tool
Brush Tool

Answers

Answer:

• Line Tool

• Rectangle Tool

• Oval Tool

• Pencil Tool

• Brush Tool.

Explanation:

When people want to animate when using the Adobe Animate CC, it is vital for them to know how to draw shapes like squares, lines, ovals, rectangles, and circles. This is to enable such individuals understand how to draw objects as it can be difficult if they do not know how to draw these shapes.

The tools that Object Drawing Mode be applied to include:

• Line Tool

• Rectangle Tool

• Oval Tool

• Pencil Tool

• Brush Tool.

When the tool is being selected, it should be noted that the option for the drawing mode will be shown in the Property Inspector panel or it can also be seen in the tools panel.

12. The best method of protecting the residential user with an Internet connection from intruders out on the Internet is to use

Answers

Answer:

Updated OS software patches

Explanation:

Firstly we need to know that patches are those software updates as well as operating system updates that addresses the vulnerabilities In a program or a products security. Software operators may decide to roll out new updates which have the power to fix performance bugs in a program as well as providing more enhanced methods of security.

Professor Gig A. Byte needs to store text made up of the characters A with frequency 6, B with frequency 2, C with frequency 3, D with frequency 2, and E with frequency 8. Professor Byte suggests using the variable length codes:
Character Code
A 1
B 00
C 01
D 10
E 0
The professor argues that these codes store the text in less space than that used by an optimal Huffman code. Is the professor correct?

Answers

Answer:

This is not true

Explanation:

The optimal Huffman code is used to encrypt and compress text files. It uses fixed-length code or variable-length code for encryption and compression of data.

The professor's character code is similar to Huffman's variable-length coding which uses variable length od binary digits to represent the word strings. The file size of the text file above is;

= 6 x 1 + 2 x 2 + 3 x 2 + 2 x 2 + 8 x 1 = 28 bits

This would be the same for both cases.

The encrypt would be the problem as the encoded and decoding of the characters B and E may cause an error.

how do i use a computer (i'm 99999 years old)

Answers

Answer:

grandma?

Explanation:

is it you?

Answer:

you  use the mouse pad and move it already and go to google and search whatever your trying to find

Explanation

i know how to work a computer

What is the next line?
>>> tupleOne = [2, 5, 10, 23, 5, 1]
>>> tupleOne.index(5,3)
A)2
B)4
C)1
D)3

Answers

Answer:

4

Explanation:got it right on edg.

Answer: 4

Explanation: got it right on edgen

Write a function that accepts a pointer to a C-string as an argument and returns the number of words contained in the string. For instance, if the string argument is 'Four score and seven years ago,' the function should return the number 6. Demonstrate the function in a program that asks the user to input a string and then passes it to the function. The number of words in the string should be displayed on the screen.

Answers

Answer:

To preserve the original format of the answer, I've added it as an attachment

Explanation:

This line defines the function

int countWords(const char ptr){

   

This line initializes number of words to 0

   int words = 0;

The following iteration is repeated until the last character in the argument is reached

   while(*(ptr) != \0){

This checks if current character is blank

       if(*ptr==  ){

If yes, then it increments number of words by 1

        words++;

 }

This moves the pointer to the next character

       ptr++;

   }

This returns the number of words in the argument

   return words+1;

}

The main begins here

int main() {

This declares user input as a character of 200 length

   char userinput[200];

This prompts user for input

   cout << Enter a string: (200 max): ;

This gets user input

cin.getline(userinput, 200);

This passes the c-string to the function and also prints the number of words

cout << There are  << countWords(userinput)<< words;

If you have 128 oranges all the same size, color, and weight except one orange is heavier than the rest. Write down a C++ Code/Algorithm to search the heavy orange, in how many steps would you be able to find it out?

Answers

Answer:

#include <iostream>

using namespace std;

void Search_heavy_orange(int arr[], int l, int r, int x)

{

int count = 0, m = 0;

while (l <= r) {

 m = l + (r - l) / 2;

 // Check if x is present at mid

 if (arr[m] == x) {

  count++;

 }

 // If x greater, ignore left half

 if (arr[m] < x) {

  l = m + 1;

  count++;

   

 }

 

 // If x is smaller, ignore right half

 else {

  r = m - 1;

  count++;

 }

}

cout << "............For Worst Case......." << endl;

cout << "Orange with heavy weight is present at index " << m << endl;

cout << "Total number of step performed : " << count << endl;

}

int main()

{

// Assuming each orange is 100 gm and the weight of heavy

// orange is 150 gm

int orange_weight[128];

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

 orange_weight[i] = 100;

}

// At worst case the heavy orange should be at last position

// inside the basket : 127

orange_weight[127] = 150;

// We will pass array , start index , last index and the search element

// as the parameters in the function Search_heavy_orange

Search_heavy_orange(orange_weight, 0, 127, 150);

return 0;

}

Explanation:

WILL MARK BRAINILY!!

Muriel's program is supposed to show flashing lights to test the user's vision, but the lights don't flash for the right
amount of time. What should Muriel do?
O assess the program
O edit the program
O debug the program
O renew the program

Answers

Answer: He/she should debug the program

Explanation: If it's not right, it's edit or renew the program.

Answer:

he should edit the program

Please have a look at the screenshot below

Answers

C. Reliability

Because of the network and recovery time



Plz give brainliest

In preemptive priority scheduling, when a process arrives at the ready queue, its priority is compared with the priority of:____________.

Answers

Answer:

Currently running process

Explanation:

In preemptive priority scheduling there is usually a form of comparison of the schedule with the other function or processes which are present in the queue also.

In preemptive priority scheduling, when a process arrives at the ready queue, its priority is compared with the priority of currently running process.

Choose the correct term to complete the sentence

The ____ function removes the element with an index of zero.

1)popleft
2)leftremove
3)leftpop

Answers

Answer:

popleft

Explanation:

Answer: pop left

Explanation: got it right on edgen

Suppose that the LC-3 instruction LD R1, DATA is located at x3100 in memory and the label DATA is located at x 310F. The machine code (in hex) for the above instruction is

Answers

Answer:

The machine code is located at x210F.

Explanation:

The DATA is located at x3100 while the DATA label is located at the x310F (in hex) in the memory which is F address away (8 bits) from the DATA itself. The machine code location is relative to the address of the DATA label.

how are you suppose To beat yunalesca on final fantasy 10 anyway

Answers

Answer:

be good at the game

Explanation:

get better

Discuss why traits such as teamwork and self representation are necessary for a successful career in the media industry

Answers

Because it helps you to be a better you it helps you to believe in yourself and to think about all the things you have in life and to help you to work together with other people through thick and thin.

Because it aids to be a better and also it helps you to believe in yourself and to think about all the things you have in life and to help you to work together with other people.

What is teamwork?

Teamwork is a group's collaborative effort to achieve a common goal or complete a task in the most effective and efficient manner.

This concept is seen in the context of a team, which is a group of interdependent individuals who work together to achieve a common goal.

Good teamwork entails a synergistic approach to work, with each individual committed to and working toward a common goal. Teamwork maximizes team members' individual strengths to bring out their best.

Good teamwork entails a synergistic approach to work, with each individual committed to and working toward a common goal. Teamwork maximizes team members' individual strengths to bring out their best.

Thus, traits such as teamwork and self representation are necessary for a successful career in the media industry.

For more details regarding teamwork, visit:

https://brainly.com/question/18869410

#SPJ2

i need help to answer this question

Answers

Answer:

The answer is D.

Explanation:

Adding a flex property denotes to that component to use a flex layout for its children.

B it needs a flex value of 1 because that means all of the other compounds will be children of this view

A job placement agency helps match job seekers with potential employers. The agency would like to design a simulation in order to help predict the likely job placement outcomes for job seekers based on historical trends and patterns. Which of the following is most likely to be a benefit of the simulation?

A. The computer simulation will be able to include more details and complexity than the real-world job placement process.
B. The computer simulation could be used to test hypotheses about patterns in the job placement process that are costly or time consuming to observe in reality.
C. The computer simulation will be able to precisely predict the real-world outcomes for each job seeker.
D. The computer simulation will remove the bias that may arise in the real-world job placement process.

Answers

Answer:

B

Explanation:

The point of simulating would be to eliminate the part of having to go through un patential applications and save time.

The option that is most likely to be a benefit of the simulation is B. The computer simulation could be used to test hypotheses about patterns in the job placement process that are costly or time-consuming to observe in reality.

Computer simulation simply refers to the process through which the behavior or outcome of a physical system can be predicted through modeling.

Since the agency would like to design a simulation so that it can forecast the likely job placement outcomes, then it should be noted that computer simulation could be used to test hypotheses about patterns in the job placement process that are costly or time-consuming to observe in reality.

In conclusion, the correct option is B.

Read related link on:

https://brainly.com/question/19703126

active cell is indentifed by its thick border true or false​

Answers

Answer:  It's identifed by its thick border so its true

Answer: true is correct
Other Questions
HELP!!! 18. A storage facility has small units designed to hold 40 - 50 large boxes, a large box on average weighs 85 lbs. On average, if someone fills the container to capacity, how much will all the boxes they store weigh?a. 3400 lbsb. 4250 lbs c. 4175 lbs d. 3825 lbs a _ variable represented by the symbol h can take on any number of numeric values and allow arithmetic operations to be performed on it Which nation is MOST LIKELY associated with restrictions on personal freedoms and voting rights... especially for women?Group of answer choicesSaudi ArabiaIsraelTurkey The table shows the number of diagonals that can be drawn from one vertex in polygon. Write an equation in function notation for the relation and find the number of diagonals that can be drawn from vertex in a 12-sided polygon. Would it be enough for you to decide whether or not you will be a part of the fish industry to augment family income? Based on the chemical equation, use the drop-down menu to choose the coefficients that will balance the chemical equation:( )Na2HPO4 ( )Na4P2O7 + ( )H2O What is one reason Britain passed the Proclamation of 1763?A) to protect the French who lived east of the AppalachiansB) to prevent costly conflict with the Native AmericansC) to expand its empire east of the AppalachiansD) to increase trade with the Native Americans find the surface area of the cylinder using pie. When the sun rises at 6:00 AM and sets at 6:00 PM in Hawaii it is which of the following? What roles did women serve in during WWI? LIST ALL How do some of the principles of Hinduism reflect the social class structure (Caste System) that evolved in Ancient India? If you are planning to be a model do you think you would get scouted or hired if you have braces? Why or why not? Friends and their friends come here puis-s.Ecris le ou les adjectifs qualificatifs correspon-dant au nomLe dsespoir dsespr, dsesprantLa frayeur La terreur La satisfactionLa colreLa passionL'pouvante-18:52210251> Geometry help, ie: linear, exponential, discrete, continuous the subject of a sentence subtract 7x2+4x-9 from 5x2+10x-5 Billy ate 5/4 pizzas and John ate 5/3 pizzas. How much more pizza did John eat than Billy? Locate a strike-slip boundary or transform boundary and what is happening there? An unsecured loan...typically has lower interest rates than a secured loan is less difficult to qualify for than a secured loan is connected to collateral, which can be taken by the lender if the loan is not paid is not connected to collateral and, therefore, a higher risk for lenders Find the equation of the line that contains the point (-1, -7) and is parallel to the line 4x + 5y = 9. Write the equation in slope-intercept form, if possible.