% Max example (used in lecture).
% The program has been improved somewhat from the version in lecture.

disp('Determine max of a set of positive integers.')
disp('Type 0 (or a negative number) to quit.')
best = 0; % Initialize
number = input('Give me number. '); % Get input number
while number > 0
if number > best % Compare number to best
best = number;
end
number = input('Give me more number. '); % Get next input number
end
if best == 0 % If no input numbers...
disp('Max is undefined')
else
fprintf('Max is %d\n', best); % Report best
end