Programming and Data Types |
The while
loop executes a statement or group of statements repeatedly as long as the controlling expression is true (1
). Its syntax is
If the expression evaluates to a matrix, all its elements must be 1
for execution to continue. To reduce a matrix to a scalar value, use the all
and any
functions.
For example, this while
loop finds the first integer n
for which n!
(n
factorial) is a 100-digit number.
Exit a while
loop at any time using the break
statement.
while Statements and Empty Arrays
A while
condition that reduces to an empty array represents a false condition. That is,
never executes statement S1
when A
is an empty array.
switch | for |