While loop

From SMath Wiki
Revision as of 11:43, 22 August 2024 by Gleb.Zaborshchikov (talk | contribs) (Created page with "'''while'''('condition','body') - Function of iterations. The cycle carries out a 'body' while the 'condition' is true. '''Advice: Choose it from the Programming palette''' '''Important note''': Inside the 'body' (line could be used) the 'condition' must change from '''true''' (different than zero) to '''false''' (zero) otherwise we can have the endless (never ending) loop. The only way in this case for while or for loop is to interrupt the calculation by choo...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

while('condition','body') - Function of iterations. The cycle carries out a 'body' while the 'condition' is true.

Advice: Choose it from the Programming palette

Important note: Inside the 'body' (line could be used) the 'condition' must change from true (different than zero) to false (zero) otherwise we can have the endless (never ending) loop. The only way in this case for while or for loop is to interrupt the calculation by choosing

File:Programming whileloop1.png

As a general rule, if the calculation is too long, make double checking of the loops.

Here is a simple example of using while loop:

File:Programming whileloop2.png


This page is inspired by legacy wiki article https://smath.info/wiki/while.ashx.