Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(1) Set-up and implementation code for a value-returning bool function Equals Yo

ID: 3937800 • Letter: #

Question

(1) Set-up and implementation code for a value-returning bool function Equals


You are not required to write a complete C++ program but must write your responses to the specific function related questions below:

QA1: Write the heading for a value-returning bool function called Equals that has two value float parameters, x and y. Document the data flow of the parameters with appropriate comments*.
QA2: Write the function prototype for the function in QA1.
QA3: Write the function definition of the function in QA1 so that it compares x and y, returning true if their difference is less than 0.000000001, and false otherwise.
QA4: Add comments to the function definition* you wrote in QA3 that also states its precondition and postcondition.

Explanation / Answer

QA1 : bool Equals(float x, float y)

Above is the function header . Data flow is pass by values that means even after calling above function ,values of actual parameters in calling function are unchanged.

QA2: bool Equals(float x, float y);

QA4:

/*

function name: Equals

parameters : float x, float y

description:

This function compares value of x and y . if their difference is less than 0.000000001 then return 1(true) or 0(false).

return type: bool

*/

Q3:

bool Equals(float x, float y) {

if ( ((x - y) < 0.000000001) || ((y - x) < 0.000000001))

return TRUE;

else

return FALSE;

}

QA2: