Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Using the while loop function

1 回表示 (過去 30 日間)
Jose Grimaldo
Jose Grimaldo 2019 年 10 月 5 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
How do i make a while loop to loop five times if the user does not enter the correct input?

回答 (1 件)

Pavel Osipov
Pavel Osipov 2019 年 10 月 5 日
編集済み: Rik 2019 年 10 月 5 日
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 件のコメント
Pavel Osipov
Pavel Osipov 2019 年 10 月 6 日
Thank you, but I don't seem to have hurt you.
darova
darova 2019 年 10 月 6 日
Baby don't hurt me

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by