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 Comments

Test it. And use StrgC to stop the run.
control-c maybe?
German keyboard.

Sign in to comment.

Answers (1)

Dongyue
Dongyue on 25 May 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.

Categories

Tags

Asked:

on 21 May 2023

Answered:

on 25 May 2023

Community Treasure Hunt

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

Start Hunting!