Create an m-file function called exam2 yourname fun. The function takes as input two values a and b. If a is bigger than b the function returns the product of a and b. If a equals b, the function returns the sum of a and b. And if b is bigger than a, the output should be zero, and a message should be displayed that reads: Value of b = "value of b" bigger than a="value of a" EXAMPLE: If a=2 and b=4 the message should read ”Value of b = 4 bigger than a = 2”
clc;
output = exam2(2,4)
function output = exam2(a,b)
if a > b
output = a*b;
elseif a == b
output = a + b;
elseif b > a
output = 0;
fprintf("Value of b = %d bigger than a = %d",b,a);
end
end
Get Answers For Free
Most questions answered within 1 hours.