hw4p1 - elseif Guess> r n = n 1 fprintf'Your guess was...

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

View Full Document Right Arrow Icon
clear;clc n = 0; r = randi(1000); c = 'y'; c while c == 'y'; Guess = input('Guess a number between 1 and 1000: '); if Guess == r n = n+1; c = 'n'; fprintf('You have guessed %.0f correctly in %0.1f guesses.', r,n);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: elseif Guess > r n = n+1; fprintf('Your guess was too high. Please guess again.\n'); elseif Guess < r n = n+1; fprintf('Your guess was too low. Please guess again.\n'); end end...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online