MATLAB: Help with conidtional loops

breakfor looploopwhile loop

Everything in the code works like I want it to except I need the code to end if a guess is higher than 10. it will display 'dumb' but also needs to end the program. I can't get it to break the code.
%%Guess Number Game
R=floor ( rand()*10 );
count=0;
for i=0:5
while(i~=5)
guess=input('Guess a number between 0 and 10')
if (R>guess)
disp('Your Guess Is Too Small')
elseif (R<guess)
disp('Your Guess Is Too Large')
elseif (R==guess)
disp('You are Correct! It is')
end
if (guess>10)
disp('DUMB')
break;
end
count=count+1
if count==3;
disp ('You Failed The Game, Try Again')
count=0;
break;
end
end
end

Best Answer

use 'return' instead of 'break'
Related Question