MATLAB Answers

0

Using the while loop function

Asked by Jose Grimaldo on 5 Oct 2019
Latest activity Commented on by darova
on 6 Oct 2019
How do i make a while loop to loop five times if the user does not enter the correct input?

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by Pavel Osipov on 5 Oct 2019
Edited by Rik
on 5 Oct 2019

fa1=false;
%fa2=true;
k=0;
while k<5
k=k+1;
if fa1==false
disp('you answer is bad, try again. ');
disp('attempt = ');disp(5-k);
else
disp('you answer is good');
break;
end%if
end%while

  4 Comments

Show 1 older comment
Rik
on 5 Oct 2019
See this page for a full explanation of the editing tools that are available.
Thank you, but I don't seem to have hurt you.
darova
on 6 Oct 2019
Baby don't hurt me

Sign in to comment.