90.6k views
0 votes
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 );

1 Answer

5 votes

Answer:

d. result = cube(4);

Step-by-step 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);

User Jishnu A P
by
4.2k points