Question
Problem 3: Do this problem by hand then double check your answer in MATLAB. (a) What will the two disp statements produce? a = 5;
Problem 3: Do this problem by hand then double check your answer in MATLAB. (a) What will the two disp statements produce?
a = 5; b = 6; c = 3;
if a > 3 && c < 7
result = a + b*c;
elseif a > 1 && b == 3
result = a*c;
elseif b == 5 || c < 5
result = b-15;
end
disp(result = );disp(result)
(b)What will the two disp statements produce?
a = 5; b = 6; c = 3;
if a > 3 && c < 7
result = a + b*c;
end
if a > 1 && b == 3
result = a*c;
end
if b == 5 || c < 5
result = b-15;
end
disp(result = );disp(result)
(c)Explain why the code in part (a) produces a different value for result than the code in part (b)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started