guessgame_forloop

guessgame_forloop - else disp ('Correct!'); break end...

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

View Full Document Right Arrow Icon
% 2/17/11 % clear clc c num = round (rand (1) * 100); for i = 5:-1:1 getnum = input('guess a number between 0 and 100:\n'); if getnum < num disp ('That is too low'); elseif getnum > num disp ('That is too high');
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: else disp ('Correct!'); break end fprintf ('You have %d times left, so ', i-1); end if getnum ~= num fprintf ('you lose! The number was %d.\n',num); end...
View Full Document

Ask a homework question - tutors are online