23.4k views
5 votes
Assume that to_the_power_of is a function that expects two int parameters and returns the value of the first parameter raised to the power of the second parameter. Write a statement that calls to_the_power_of to compute the value of cube_side raised to the power of 3 and that associates this value with cube_volume.

1 Answer

3 votes

Answer:

#include <iostream>

#include <math.h>

using namespace std;

int to_the_power_of(int first, int second){

int result = pow(first, second);

return result;

}

int main()

{

int side;

cout<<"Enter the side of cube: ";

cin>>side;

int volume = to_the_power_of(side, 3);

cout<<"The volume is "<<volume<<endl;

return 0;

}

Step-by-step explanation:

include the library iostream and math.h for using the input/output instruction and pow() function.

create the main function and declare the variable.

then, print the message for asking to enter the value from user.

the enter value is then store in the variable using cin instruction.

then, call the function with two parameters. program control move to the define function and calculate the first parameter raised to the power of the second parameter.

then return the result to the main function and finally print the result.

User Broinjc
by
5.4k points