forked from LegoGMI/ManualeGM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path401_12_for.html
57 lines (45 loc) · 1.26 KB
/
401_12_for.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>For statement</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body background="images/back.gif">
<!--START-->
<h3>For statement</h3>
A for statement has the form
<p>
<blockquote>
<pre><b>for</b> (<statement1> ; <expression> ;<statement2>) <statement3></pre>
</blockquote>
<p>
This works as follows. First statement1 is executed. Then the expression
is evaluated. If it is true, statement 3 is executed; then statement 2 and
then the expression is evaluated again. This continues until the
expression is false.
<p>
This may sound complicated. You should interpret this as follows. The
first statement initializes the for-loop. The expression tests whether the
loop should be ended. Statement2 is the step statement that goes to the
next loop evaluation.
<p>
The most common use is to have a counter run through some range.
<p>
<b>Example</b><br>
The following program initializes an array of length 10 with the values 1-
10.
<p>
<blockquote>
<pre>
{
<b>for</b> (i=0; i<=9; i+=1) list[i] = i+1;
}
</pre>
</blockquote>
<!--END-->
</body>
</html>
<!-- KEYWORDS
for statement
for loop
-->