Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
What does this print out?
조회 수: 1 (최근 30일)
이전 댓글 표시
a = 3;
b = a;
a = 1;
while (b<a)
b = b + 1;
disp(b)
end
I thought this would create an infinite loop is that correct?
댓글 수: 0
답변 (1개)
Paulo Silva
2011년 5월 9일
it never prints, the condition is false
do this before the loop
b<a %replacing b and a by their first values you get 3<1
answer is 0 because the condition is false thus the loop never begins
댓글 수: 3
Paulo Silva
2011년 5월 9일
the condition is tested in the while line, if true the while begins, does what's inside it and in the end it tests again the condition, if false the code inside the while loop is "ignored"
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!