Whileloop output calculation?

1 Ansicht (letzte 30 Tage)
Entle
Entle am 21 Mai 2023
Beantwortet: Dongyue am 25 Mai 2023
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 Kommentare
Walter Roberson
Walter Roberson am 21 Mai 2023
control-c maybe?
Torsten
Torsten am 21 Mai 2023
German keyboard.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Dongyue
Dongyue am 25 Mai 2023
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.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by