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.

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by