Whileloop output calculation?

Given the matlab code below
x1=15; while x1>10 x1=x1*(x1+1); end disp(x1)
State the output that the code will yield.

3 件のコメント

Torsten
Torsten 2023 年 5 月 21 日
Test it. And use StrgC to stop the run.
Walter Roberson
Walter Roberson 2023 年 5 月 21 日
control-c maybe?
Torsten
Torsten 2023 年 5 月 21 日
German keyboard.

サインインしてコメントする。

回答 (1 件)

Dongyue
Dongyue 2023 年 5 月 25 日

1 投票

The condition x1>10 is always true, making this while loop infinite. Consequently, the loop will continue indefinitely without producing any output since the disp(x1) command will never execute.

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

タグ

質問済み:

2023 年 5 月 21 日

回答済み:

2023 年 5 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by