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

T-Mobile @ 24%.-, 1:43 PM Week 9 Activities start with a verb. 2) Please bring y

ID: 3738210 • Letter: T

Question

T-Mobile @ 24%.-, 1:43 PM Week 9 Activities start with a verb. 2) Please bring your solutions in on paper; we are finding that solutions brought in on laptops are a little hard to manage. 1) Write a function that accepts two numbers as parameters and returns the larger of the two 2) Write a function that accepts three numbers as parameters and returns the largest of the three; the function may not use any if statements, but must use the function generated in item #1 3) Write a function that returns true if two numbers accepted as parameters are equal; this function must also not use any if statements

Explanation / Answer

Ques 1.

function [x] = larger(a, b)

    % if a is bigger

    if a > b

       

        x = a;

       

    % if b is bigger

    else

       

        x = b;

       

    end

end

Ques 2.

function [x] = larger(a, b, c)

    % if a is largest

    if a > b && a >c

       

        x = a;

       

    % if b is largest

    elseif b > a && b > c

       

        x = b;

       

    % if c is largest

    else

       

        x = c;

       

    end

end

Ques 3.

function flag = isEqual(a, b)

    % if a and b are equal

    if a == b

      

        flag = true;

       

    % if a and b are not equal

    else

       

        flag = false;

       

    end

end