99.3k views
1 vote
function maxSum = CalculateSum(userNum1, userNum2, userNum3) maxSum = MaxValue(userNum1, userNum2) + userNum3; end % Define a function MaxValue that returns the largest input value % Function inputs: numA, numB % Function output: maxNum % function maxNum ...

1 Answer

2 votes

Answer:

Check the explanation

Step-by-step explanation:

%Define the function CalculateSum().

function maxSum = CalculateSum(userNum1,userNum2,userNum3)

%Compute the maxSum.

maxSum = MaxValue(userNum1,userNum2)+userNum3

%End of the function CalculateSum().

end

%Define the function MaxValue().

function maxNum = MaxValue(numA,numB)

%Compare the elements numA and numB.

if(numA>numB)

%Store the value of numA in maxNum.

maxNum = numA;

%The else part.

else

%Store the value of numA in maxNum.

maxNum = numB;

%End of the if-else.

end

%End of the function MaxValue().

end

%Run the following code in the command prompt.

%Call the function CalculateSum().

CalculateSum(4, 7, 3)

The below image is the screenshot of the complete code:

function maxSum = CalculateSum(userNum1, userNum2, userNum3) maxSum = MaxValue(userNum-example-1
User Zamotic
by
4.4k points