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
rusak2 [61]
3 years ago
8

Consider the provided C++ code in the main.cpp file: The function func2 has three parameters of type int, int, and double, say a

, b, and c, respectively. Write the definition of func2 so that its action is as follows: Prompt the user to input two integers and store the numbers in a and b, respectively. If both of the numbers are nonzero: If a >= b, the value assigned to c is a to the power b, that is, aᵇ. If a < b, the value assigned to c is b to the power a, that is, bᵃ. If a is nonzero and b is zero, the value assigned to c is the square root of the absolute value of a. If b is nonzero and a is zero, the value assigned to c is the square root of the absolute value of b. Otherwise, the value assigned to c is 0. The values of a, b, and c are passed back to the calling environment. After completing the definition of the func2 and writing its function prototype, run your program.
Computers and Technology
1 answer:
TEA [102]3 years ago
3 0

Answer:

  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. struct data {
  5.    int a;
  6.    int b;
  7.    double c;
  8. };
  9. data func2(){
  10.    
  11.    int a, b;
  12.    double c;
  13.    data d;
  14.    
  15.    cout<<"Input first number: ";
  16.    cin>>a;
  17.    cout<<"Input second number: ";
  18.    cin>>b;
  19.    
  20.    if(a != 0 && b != 0){
  21.        if(a >= b){
  22.            c = pow(a, b);
  23.        }else{
  24.            c = pow(b, a);
  25.        }
  26.    }
  27.    else if(a != 0 && b == 0){
  28.        c = sqrt(abs(a));
  29.    }
  30.    else if(a == 0 && b != 0){
  31.        c = sqrt(abs(b));
  32.    }
  33.    else{
  34.        c = 0;
  35.    }
  36.    
  37.    d.a = a;
  38.    d.b = b;
  39.    d.c = c;
  40.    return d;
  41. }
  42. int main()
  43. {
  44.    data d = func2();
  45.    cout<<d.a<<" "<<d.b<<" "<<d.c<<"\n";
  46.    
  47.    return 0;
  48. }

Explanation:

Since the func2 is expected to return a, b and c and therefore we create a struct data to hold the return values (Line 6 - 10);

Next, we create the func2 that will return a struct data (Line 12).

Declare three required variables, a, b and c (Line 14 -16) and prompt user to input a and b values (Line 18 - 21).

Next, create nested if else condition that fulfill all the condition requirements as stated in the question (Line 23 - 38) and calculate the value a and b and then assign the result to c accordingly. Please note, we use c++ math library methods such as pow, abs and sqrt to get value from calculation that involves power (Line 25, Line 27), absolute (Line 31, Line 34) and square root (Line 31, Line 34).

At last, set the value a, b and c to the struct d and return d as output (Line 43).

You might be interested in
Sdq1fdszgdSHTGafeges'
kumpel [21]

Answer:

iooooooooooooooooooooo

Explanation:

ooooooooooooooo

oooo9ooooo9oooooooooo

ooooooooooooooppppooooooooooo

oooooooooooo

ooooooooooooooooooooo

6 0
3 years ago
A technician wants to replace a failing power supply on a high-end gaming computer. which form factor should the technician be l
Semmy [17]

A technician need to use the form factor or the  technician be looking for what we call EPS12V.

<h3>What is an EPS power connector?</h3>

The EPS connector is known to be used to supply power to the  motherboard CPU socket and the PCI is known to be one that functions to express connector.

Note that this is said to be a server standard (EPS12V) and it is also known to be one that can be said to be a desktop standard (ATX12V).

Note that the EPS12V is one that is known to always be seen in an 8-pin CPU connector and therefore, A technician need to use the form factor or the  technician be looking for what we call EPS12V.

Learn more about technician from

brainly.com/question/2328085

#SPJ1

5 0
2 years ago
What would you NOT use a router for? *
Alla [95]

Answer:

<h2><u>A</u><u>.</u><u> </u><u>To</u><u> </u><u>run</u><u> </u><u>applications</u><u> </u><u>on</u><u> </u><u>your</u><u> </u><u>computer</u></h2>

3 0
3 years ago
Suppose you are among those who believe that the NLRA should be transformed. What arguments support the claim that a complete ov
miss Akunina [59]

Answer:

See explanation below.

Explanation:

Note: This question is not complete. The complete question is therefore provided before answering the question follows:

Suppose you are among those who believe that the NLRA should be transformed. What arguments support the claim that a complete overhaul is necessary? What alternative models might be considered as a replacement for the NLRA model of exclusive representation?

The explanation of the answers is now provided as follows:

a. What arguments support the claim that a complete overhaul is necessary?

The adversarial nature of labor relations in the United States, which many claim is produced by the National Labor Relations Act's (NLRA)'s very existence, is the fundamental reason for its transformation. In a global economy, supporters of transformation say that adversarialism is undesirable for employees and employers because it makes representation and profit maximization more difficult. The principles of exclusive representation and majority support are specific aspects of the NLRA that promote adversarialism.

The fact that it is compulsory for a union to win the support of a majority of workers, the process of representation results into a tone of a "u versus. them". As a result, both sides try to make the other look bad in the eyes of the employees who will vote.

Based on the above, a  complete overhaul is necessary.

b. What alternative models might be considered as a replacement for the NLRA model of exclusive representation?

Giving nonmajority unions legal protection by requiring employers to negotiate with them is one alternative to replace the NLRA model of exclusive representation. Under this, the contracts would not cover all employees; only those who are union members would be covered.

Another alternative is that work councils could also be used to supplement or replace the certification process. Employee free speech rights, wrongful dismissal procedures, employee participation on business boards of directors, and the right to workplace information are all potential transformation factors that might be taken into consideration.

3 0
2 years ago
What is Gpu in simple terms ​
Bingel [31]
Graphic processing unit !!?????!!??!??!?!!?!!?
5 0
3 years ago
Read 2 more answers
Other questions:
  • Write a program that reads in 10 numbers from the user and stores them in a 1D array of size 10. Then, write BubbleSort to sort
    13·1 answer
  • ________ computers are specially designed computer chips that reside inside other devices, such as a car. Select one: A. Tablet
    11·2 answers
  • Notice in the topology there are 3 network ranges that would be translated based on the ACL created. What will happen if more th
    6·1 answer
  • I wiil mark brainlist ​
    8·1 answer
  • Ad identifies and describes at least four ways to prevent downloading of spyware, adware, and viruses to computer
    9·1 answer
  • 1
    13·1 answer
  • What is the full form of 'Rom<br>​
    7·2 answers
  • I am stuck on these 2 questions. Can someone help me please?
    10·1 answer
  • Just help :(((((((((((((((((((((((((((((((((((
    14·1 answer
  • If you want to remove the autocorrect options button from the screen, you can press the ____ key.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!