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
Macro photographs are what type of photographs? A. Close-up B. Telephoto C. Abstract D. All of the above
scZoUnD [109]

Answer:

A

Explanation:

they are close up. they are not telephoto or abstract

marco can be telephoto, but it is not nessacarily always telephoto. marco is by definition a close up photo

5 0
3 years ago
Complete the statement below with the correct term.
Lilit [14]

Answer:

<em>Every </em><em>couple</em><em> </em><em>of </em><em>month </em><em>or </em><em>whatever </em><em>you </em><em>give </em><em>it </em><em>to </em><em>someone</em><em> </em><em>else</em>

8 0
2 years ago
Explain the steps in starting the MS Access from the Start Menu.​
blondinia [14]

Explanation:

<em>As</em><em> </em><em>with</em><em> </em><em>most</em><em> </em><em>windows</em><em> </em><em>programs</em><em> </em><em>Access</em><em> </em><em>can</em><em> </em><em>be</em><em> </em><em>executed</em><em> </em><em>by</em><em> </em><em>navigation</em><em> </em><em>the</em><em> </em><em>start</em><em> </em><em>menu</em><em> </em><em>in</em><em> </em><em>the</em><em> </em><em>lower</em><em> </em><em>left</em><em> </em><em>hand</em><em> </em><em>corner</em><em> </em><em>of</em><em> </em><em>the</em><em> </em><em>windows</em><em> </em><em>desktop</em><em>. </em><em>To</em><em> </em><em> </em><em>Acess</em><em>,</em><em> </em><em>click</em><em> </em><em>on</em><em> </em><em>the</em><em> </em><em>start</em><em> </em><em>button</em><em>,</em><em> </em><em>then</em><em> </em><em>the</em><em> </em><em>programs</em><em> </em><em>menu</em><em> </em><em>then</em><em> </em><em>move</em><em> </em><em>to</em><em> </em><em>the</em><em> </em><em>Microsoft</em><em> </em><em>Office</em><em> </em><em>m</em><em>enu</em><em> </em><em>a.d</em><em> </em><em>finally</em><em> </em><em>click</em><em> </em><em>on</em><em> </em><em>the</em><em> </em><em>Microsoft</em><em> </em><em>Access</em><em> </em><em>menu</em><em> </em><em>item</em><em>. </em>

6 0
2 years ago
Data from RAM may be placed where to free up space? Log file Swap file Word file Print spool file
hjlf

Answer:

Swap file

Explanation:

5 0
3 years ago
Ill give brainliest if possible
AlekseyPX
I can’t see that zoom it in
8 0
3 years ago
Read 2 more answers
Other questions:
  • Following a company on likedin is most similar to
    8·1 answer
  • Your new home has a vacuum system. what kind of computer is controlling it?
    5·1 answer
  • Which method can help you prevent RSI while using a keyboard?
    14·1 answer
  • The optional feature in a business letter is
    10·1 answer
  • A virus is a self-replicating program that produces its own code by attaching copies of it into other executable codes.
    7·1 answer
  • You want to boot a linux system into singer user mode/ what options might you add to a linux kernel options list in a boot loade
    9·1 answer
  • What is Automation ? Please give an example ?
    14·1 answer
  • I need help picture above
    15·2 answers
  • PLEASE HELP!! WILL MARK BRAINLIEST!!
    15·1 answer
  • What is intellectual property rights law ?​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!