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
PtichkaEL [24]
3 years ago
12

Write the definition of a function that takes as input the three numbers. The function returns true if the first number to the p

ower of the second number equals the third number; otherwise, it returns false. (Assume that the three numbers are of type double.)

Computers and Technology
1 answer:
sattari [20]3 years ago
3 0

Answer:

I am writing a C++ program.

Here is the function CheckPower() which is a bool return type function which means it will return either true of false. This function has three double type parameters. This function returns true if the first number to the power of the second number equals the third number; otherwise, it returns false.

bool CheckPower(double number1, double number2, double number3)

{

   double power; // stores value of number1 to the power number2

   power = pow(number1,number2); // pow() function to computer power

   if (power==number3) // if the value of power is equal to third no number3

       return true; // returns true

   else // if above condition evaluate to false then returns false

       return false;

}

Explanation:

Lets take the values of number1 = 3, number2 = 2 and number3 = 9 to understand the above function.

The pow() function is a power function to calculate the result of number1 raised to the power of number2. Here number1 is the base number and number2 is exponent number. As number1 = 3 and number2 = 2 so this is equivalent to 3² . So 3 raise to the power 2 is 9. The value stored in power is 9.

power = 9

Next, the if condition checks if the value in power is equal to the value of number3. The value of number3 is 9 and the value in power variable is also 9 so the If condition evaluates to true. So the if part is executed which returns true.

If the value of number3 is, lets say, 10 then the If condition evaluates false as the value of power is not equal to value of number3. So the else part is executed which returns false.

If you want to see the output of this function you can write a main() function as following:

int main()

{   double num1, num2, num3;

   cout << "enter first number: ";

   cin >> num1;

   cout << "enter second number: ";

   cin >> num2;

   cout << "enter third number: ";

   cin >> num3;

   if(CheckPower(num1, num2, num3))

   { cout<<"True";    }

   else

   { cout<<"False";  }    }

This is a main() function which asks the user to enter the values of three numbers num1, num2 and num3. The if condition calls CheckPower() function to check if the first number to the power of the second number equals the third number. If this condition evaluates to true, the message True is displayed on the screen otherwise message False is displayed on output screen.

The screen shot of program along with its output is attached.

You might be interested in
Which of the following scenarios can best be addressed by operations management?
Alborosie

Answer:

We need to shorten the time it takes to pick a customer order.

Explanation:

The operations management is the department in charge of supervising the operations related to the production and delivery of a product or a service of a company to its customers.

It would then them who would be in charge of reviewing the process or steps it takes to pick a customer order.

The other options are issues for the human resources department.

7 0
3 years ago
What is the cffa act
garri49 [273]

CFAA is an acronym that stands for Computer Fraud and Abuse Act. It is an anti-hacking bill that was passed to amend an existing computer fraud law. It aims to strengthen cyber security by forbidding access to computers without authorization.

3 0
2 years ago
Read 2 more answers
Can anyone suggest me any good complete isekai anime..​
Fofino [41]
I suggest you watch hentaaii my boyy


8 0
2 years ago
Read 2 more answers
Systems such as smartphones, appliances, game controllers, cable set-top boxes and automobiles that contain small computers are
Setler [38]

I guess the correct answer is Embedded system.

Systems such as smartphones, appliances, game controllers, cable set-top boxes and automobiles that contain small computers are called Embedded systems.

8 0
2 years ago
Create a Produceclass that hasan instance variable of type Stringfor the name, appropriate constructors, appropriate accessor an
Nezavi [6.7K]

Answer:

you suck

Explanation:

5 0
3 years ago
Other questions:
  • Which of the following is an encryption tool that allows users to encrypt files and folders by simply right-clicking a given obj
    10·2 answers
  • Which is not an example of a lighter-than-air gas?
    5·2 answers
  • A function operates on this, which may consist of a constant, a cell reference, or another function.
    7·1 answer
  • Person-name: String+setName(String name): void+getName(): String^Student-studentID: long+Student(String sname, long sid)+setID()
    10·1 answer
  • Which of the following is true regarding data analysis? a. Disciplines and professions do not provide guidance on data analysis.
    6·2 answers
  • [This is on Edhesive (coding and programming)]
    8·2 answers
  • The process of sending a result back to another part of the program is
    14·1 answer
  • While working in a group of two the members are not getting along. You bring the two members together so they can discuss this i
    11·1 answer
  • The main function of a(n) ____________________ is to centralize access control for the network by keeping an eye on both inbound
    9·1 answer
  • What are the different elements of a window?​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!