Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Using the while loop function

1 vue (au cours des 30 derniers jours)
Jose Grimaldo
Jose Grimaldo le 5 Oct 2019
Clôturé : MATLAB Answer Bot le 20 Août 2021
How do i make a while loop to loop five times if the user does not enter the correct input?

Réponses (1)

Pavel Osipov
Pavel Osipov le 5 Oct 2019
Modifié(e) : Rik le 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 commentaires
Pavel Osipov
Pavel Osipov le 6 Oct 2019
Thank you, but I don't seem to have hurt you.
darova
darova le 6 Oct 2019
Baby don't hurt me

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by