While loop: Difference between revisions
Jump to navigation
Jump to search
(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...") |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
'''Advice: Choose it from the Programming palette''' | '''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 | '''Important note''': Inside the 'body' ([[line block]] 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: | [[File:En_programming_whileloop1.png]] | ||
As a '''general rule''', if the calculation is too long, make double checking of the '''loops'''. | As a '''general rule''', if the calculation is too long, make double checking of the '''loops'''. | ||
Line 11: | Line 11: | ||
Here is a simple example of using '''while''' loop: | Here is a simple example of using '''while''' loop: | ||
[[File: | [[File:En_programming_whileloop2.png]] | ||
Latest revision as of 12:11, 12 September 2024
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 block 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
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:
This page is inspired by legacy wiki article https://smath.info/wiki/while.ashx.