144k views
4 votes
Assume you need to test a function named max. The function max receives two int arguments and returns the larger. Write the definition of driver function testmax whose job it is to determine whether max is correct. So testmax returns true if max is correct and returns false otherwise.

1 Answer

3 votes

Answer:

bool testmax() // function definition

{

//demonstrating working of the function max

if (max(1,2) == 2 && max(2,1) == 2 && max(1,1)==1)

return true; // true if the max functions correctly

else

return false; //false for wrong functioning of max

}

Step-by-step explanation:

Driver function:

A driver function is the one which demonstrates the code of library-style and solves problem. If a code contains some class A, driver functions would be functions that are in your code just to show that class A behaves as expected.

User CarbonDry
by
5.6k points