Using the while loop function

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일

0 개 추천

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

darova
darova 2019년 10월 5일
Mr. Pavel, please use special button for code inserting
11Capture.PNG
Rik
Rik 2019년 10월 5일
See this page for a full explanation of the editing tools that are available.
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

이 질문은 마감되었습니다.

태그

질문:

2019년 10월 5일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by