% Lab/Exercise 3 Solution disp('Welcome to Lab 3'); % Use DIS's READINT function (see lectures): size = readInt(1,10,'Enter a size [1,10]: '); % Special case: % Print first row % Could have folded this into main algorithm for col=1:size-1 fprintf(' '); end fprintf('*\n'); % Print subsequent rows of stars by % printing blanks, then a star, then blanks % then a final star: for row=2:size for col=1:size-row fprintf(' '); end fprintf('*'); for col=size-row+2:size-1 if row < size fprintf(' '); else fprintf('*'); % for last row end end fprintf('*\n'); end