**[M-2] for** -- for (exp1; exp2; exp3) stmt

__Syntax__

**for (***exp1***;** *exp2***;** *exp3***)** *stmt*

**for (***exp1***;** *exp2***;** *exp3***) {**
*stmts*
**}**

where *exp1* and *exp3* are optional, and *exp2* must evaluate to a real
scalar.

__Description__

**for** is equivalent to

*exp1*
**while (***exp2***)** **{**
*stmt(s)*
*exp3*
**}**

*stmt(s)* is executed zero or more times. The loop continues as long as
*exp2* is not equal to zero.

__Remarks__

To understand **for**, enter the following program

**function example(n)**
** {**
** for (i=1; i<=n; i++) {**
** printf("i=%g\n", i)**
** }**
** printf("done\n")**
** }**

and run **example(3)**, **example(2)**, **example(1)**, **example(0)**, and **example(-1)**.

Common uses of **for** include

**for (i=1; i<=rows(A); i++) {**
**for (j=1; j<=cols(A); j++) {**
...
**}**
**}**