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
How is sharepoint used in organization today?
tatyana61 [14]
<span>To build a team site and collaborate with your colleagues</span>
8 0
3 years ago
Which tool encrypts entire drives, rendering them unusable unless one possesses the correct key to unlock the drive?
xxMikexx [17]

Answer:

Whole disk encryption.

Explanation:

Whole disk encryption, also known as, the full disk encryption is a tool that encrypts the entire drive. The whole disk encryption protects the whole hard drive from unwanted visitor to enter into your system.

<u>This tool protects your entire data, softwares, files, etc stored in the hard drive. Whole disk encryption cedes the entire hard drive unusuable untill correct key is entered to unlock the drive.</u>

Thus the correct answer is 'whole disk encryption.

8 0
3 years ago
What would a match() property that passed the expression /^[0-9]/ check for?
lord [1]

Answer:

E

Explanation:

I took the test

7 0
2 years ago
Read 2 more answers
The programming interface for a legacy motor controller accepts commands as binary strings of variable lengths.
victus00 [196]

Answer:

The answer is "Option a"

Explanation:

The given question is incomplete, that's why its correct solution can be defined as follows:

The above-given question is the part of the Binary Autocomplete, in which this Autocomplete function would be a full word or sentence after just a few other letters were entered into the system. It approach improves text taking appropriate on smartphone devices of particular because every letter should not be written in such a single phrase.  

3 0
3 years ago
NO LINKS OR I WILL DELETE YOUR FORTNITE ACCOUNT
ozzi

Answer:

can i have ur fortnite account if u hav one and dont use it :) i only say that cuz u mentioned fortnite

Explanation:

with the free version you can add effects (cheap effects) cut the video, crop some parts. and posting leaves a watermark until u buy money

5 0
2 years ago
Other questions:
  • How might writing an online journal be different than writing in a paper one ​
    15·2 answers
  • Co to jest podprogram (procedura lub funkcja)? Zaznacz poprawną odpowiedź. a) Wielokrotne powtarzanie tych samych poleceń. b) Wy
    8·1 answer
  • Gregory Yob is associated with which of these games?
    7·2 answers
  • Which of the following might cause a shift from PPF1 to PPF2? I. A new source of high quality denim fabric. II. A new lighter me
    12·1 answer
  • What are Important points to include about preventing the download of malware?
    14·1 answer
  • What is another name for a numbered list
    6·1 answer
  • Write a logical expression using only and, or and not that is equivalent to the Exclusive NOR (XNOR) gate on 2 inputs, called in
    15·1 answer
  • What is the launching of a 3-D map called?
    12·1 answer
  • When viewing an e-book section of an assignment in launchpad, you can return to your main course page at any time by clicking th
    5·1 answer
  • Alice is watching a speech over the internet. what type of message is alice attending to?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!