Consider the following functions. What would be the response to the command line
ID: 3867576 • Letter: C
Question
Consider the following functions. What would be the response to the command line t = fun(5, 2) + fun(3, 4)? function [t] = fun(x, y) if x == 0 t = y: else t = fun(x - 1, x + y): end end Consider the following functions. What would be the response to the call foo(5)? Note that there is both a returned value and side effects. function x = foo(n) if mod (n, 2) == 1 disp(n): end if n > = 2 x = n - 2 + 3 * bar(n - 1): else x = 3: end function x = bar(n) if mod(n, 3) = 1 disp(n) end if n > = 2 x = 2 * n + 2 - foo(n - 1) else x = -2: endExplanation / Answer
1.) For the command line fun(5,2) + fun (3,4) this will happen:
2.)For the function call foo(5) we will get the following output.
Please rate the answer if it helped........Thankyou
Hope this helps......
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.