Complete the code to check if a number is positive.
if [1] > 0 disp('Positive number'); end
The variable num is used to check if it is greater than zero.
Complete the code to execute the else block when the number is not positive.
if num > 0 disp('Positive'); [1] disp('Not positive'); end
elseif without a condition.The else keyword runs the code when the if condition is false.
Fix the error in the loop to print numbers from 1 to 5.
for i = 1:[1] disp(i); end
The loop should run from 1 to 5, so the upper limit is 5.
Fill both blanks to create a loop that prints even numbers from 2 to 10.
for num = [1]:[2]:10 disp(num); end
The loop starts at 2 and increments by 2 to print even numbers.
Fill all three blanks to create a conditional that prints 'Even' or 'Odd' for a number.
if mod([1], [2]) == [3] disp('Even'); else disp('Odd'); end
The mod function checks if num divided by 2 has remainder 0 (even).
