GuessGameChar

GuessGameChar - end if (gnum < num) disp ('Too...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
% Same as GuessGame, except uses string comparison for input clc clear num = round(rand(1)*25 + 97); num = char(num); r = 'yes'; while strcmpi('yes', r) gnum = input ('Guess number between 0 & 100: ','s'); gnum = gnum + 32; % Shifts capital to lower case range (97 to 122)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: end if (gnum < num) disp ('Too low') elseif (gnum > num) disp ('Too high') else disp ('You win') break end r = input ('Do you want to guess again? ','s'); end if gnum ~= num fprintf ('You lose! The number is %d\n', num) end...
View Full Document

This note was uploaded on 05/01/2011 for the course HCSC 110 taught by Professor Amosjohnson during the Spring '11 term at Morehouse.

Ask a homework question - tutors are online