From science to arts, IDNLearn.com has the answers to all your questions. Our community provides timely and precise responses to help you understand and solve any issue you face.

A program contains the following prototype:
int cube( int );
and function:
int cube( int num )
{
return num * num * num;
}
Which of the following is a calling statement for the cube function that will cube the value 4 and save the value that is returned from the function in an integer variable named result (assume that the result variable has been properly declared)?
a. cube( 4 );
b. cube( 4 ) = result;
c. result = cube( int 4 );
d. result = cube( 4 );


Sagot :

Answer:

d. result = cube(4);

Explanation:

Given

Prototype: int cube(int num);

Function: int cube(int num)  {  return num * num * num; }

Required

The statement to get the cube of 4, saved in result

To do this, we have to call the cube function as follows:

cube(4);

To get the result of the above in variable result, we simply assign cube(4) to result.

So, we have:

result = cube(4);