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 comentarios

Torsten
Torsten el 21 de Mayo de 2023
Test it. And use StrgC to stop the run.
Walter Roberson
Walter Roberson el 21 de Mayo de 2023
control-c maybe?
Torsten
Torsten el 21 de Mayo de 2023
German keyboard.

Iniciar sesión para comentar.

Respuestas (1)

Dongyue
Dongyue el 25 de Mayo de 2023

1 voto

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.

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 21 de Mayo de 2023

Respondida:

el 25 de Mayo de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by