% Script ForWhile
% Practice converting a for-loop to an equivalent while-loop

% These two loops display the same thing...
clc
disp('For loop output...')
for k=1:5
fprintf('k = %3d\n',k)
end

disp(' ')

disp('While loop output...')
k = 1;
while(k<=5)
fprintf('k = %3d\n',k)
k = k+1;
end

% (a) Change the for-loop statement to for k=1:2:10
% and modify the while-loop so it does the same thing.

% (b) Change the for-loop statement to for k=6:-1:3
% and modify the while-loop so it does the same thing.

% (c) Change the for-loop statement to for k=100:-20:30
% and modify the while-loop so it does the same thing.