Answers to the MATLAB Questions on Loops, Statements and Functions

Questions 1-8: Variable Type and Value
1)
logical 0
(b|c) is true, but ~d is false (d=17 is non-zero)
2)
logical 1
Both u (true) and v (-17, non-zero) are true
3)
logical 0
v1 (0) is false, so AND operation yields false
4)
double 0
r2 = 0.0 (double), r1 ≈ 1.0472, result is 0.0
5)
logical 1
mass*acc = -22 (non-zero), logical() converts to true
6)
logical 1
X (1) is true, ~y (true), z (2) is true
7)
logical 0
u & v are true, but w (0) is false
8)
double 0
r2 (false) converts to 0 in division
Questions 9-11: Script Output
9)
2, 36, 150
Loop iterations: j=1,k=1 → 2; j=3,k=2 → 36; j=5,k=3 → 150
10)
Four times
Loop runs for count = 1, 2, 3, 4 (stops when count=5 > L=3)
11)
-5
myfunc(12,8) calculates 12 - 17 = -5 (y=17 inside function doesn't affect output y)
End of the Practice. Hopefully, you got many answers correct!


For more details, please contact me here.