Type the following program and save it as whilex.m in your current directory. Execute the
program and see if it works correctly. If not, use the debugger to correct the problem.
whilex.m
function whilex()
% Generates the number in difference of 5
num = 1;
disp(‘The multiples of 5 between 1 and 40 are: ‘)
while (num ~= 40)
num = num + 5;
disp(num)
end
Direction: This is an example of the problem that can arise in an infinite (or nonterminat-
ing) loop. These usually result in the omission of statement(s) in the loop body which will
cause the condition in the “while to become false at some ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.