Answer:
maxSum = FindMax(numA, numB) + FindMax(numY, numZ);
The maxSum is a double type variable which is assigned the maximum of the two variables numA numB PLUS the maximum of the two variables numY numZ using FindMax function. The FindMax() method is called twice in this statement one time to find the maximum of numA and numB and one time to find the maximum of numY numZ. When the FindMax() method is called by passing numA and numB as parameters to this method, then method finds if the value of numA is greater than that of numB or vice versa. When the FindMax() method is called by passing numY and numZ as parameters to this method, then method finds if the value of numY is greater than that of numZ or vice versa. The PLUS sign between the two method calls means that the resultant values returned by the FindMax() for both the calls are added and the result of addition is assigned to maxSum.
Explanation:
This is where the statement will fit in the program.
#include <iostream>
using namespace std;
double FindMax(double num1, double num2) {
double maxVal = 0.0;
if (num1 > num2) { // if num1 is greater than num2,
maxVal = num1; // then num1 is the maxVal. }
else {
maxVal = num2; // num2 is the maxVal. }
return maxVal; }
int main() {
double numA;
double numB;
double numY;
double numZ;
double maxSum = 0.0;
maxSum = FindMax(numA, numB) + FindMax(numY, numZ);
cout << "maxSum is: " << maxSum << endl; }
Lets take an example to explain this. Lets assign values to the variables.
numA = 6.0
numB = 3.0
numY = 4.0
numZ = 9.0
maxSum =0.0
maxSum = FindMax(numA, numB) + FindMax(numY, numZ);
FindMax(numA,numB) method call checks if numA>numB or numB>numA and returns the maximum of the two. Here numA>numB because 6.0 is greater than 3.0. So the method returns numA i.e. 6.0
FindMax(numY, numZ) method call checks if numY>numZ or numZ>numY and returns the maximum of the two. Here numZ>numY because 9.0 is greater than 4.0. So the method returns numZ i.e. 9.0
FindMax(numA, numB) + FindMax(numY, numZ) this adds the two values returned by the method FindMax for each call.
FindMax returned maxVal from numA and numB values which is numA i.e. 6.0.
FindMax returned maxVal from numY and numZ values which is numZ i.e. 9.0.
Adding these two values 9.0 + 6.0 = 15
So the complete statement FindMax(numA, numB) + FindMax(numY, numZ) gives 15.0 as a result.
This result is assigned to maxSum. Hence
maxSum = 15
To see the output on the screen you can use the print statement as:
cout<<maxSum;
This will display 15