
% Lab 7 Solutions
% CS 1109, Summer 2011
% July 25

% This script prompts the user to enter a number and prints all the odd
% numbers that are less than or equal to the user-supplied number. This
% process is repeated until the user enters either 0 or a negative number.

clc
clear

% Set this to 1 initially so that we enter the while-loop the first time
upperBound = 1;

% The while-loop repeats as long as the user keeps entering positive
% numbers
while (upperBound > 0)

    upperBound = input('Please enter a number: ');
    
    % Once the user enters a number, print all the odd numbers that are
    % less than or equal to the supplied bound
    for i = 1 : 2 : upperBound
        fprintf('%d ', i);
    end
    fprintf('\n');
    
end
