1 <!DOCTYPE HTML PUBLIC
"-//W3O//DTD W3 HTML 2.0//EN">
2 <!-- This collection of hypertext pages is Copyright 1995, 1996 by Steve Summit. -->
3 <!-- This material may be freely redistributed and used -->
4 <!-- but may not be republished or sold without permission. -->
7 <link rev=
"owner" href=
"mailto:scs@eskimo.com">
8 <link rev=
"made" href=
"mailto:scs@eskimo.com">
9 <title>Chapter
3: Statements and Control Flow
</title>
10 <link href=
"sx2g.html" rev=precedes
>
11 <link href=
"sx3a.html" rel=precedes
>
12 <link href=
"top.html" rev=subdocument
>
15 <H1>Chapter
3: Statements and Control Flow
</H1>
17 <p>Statements are the ``steps'' of a program.
18 Most statements compute and assign values
20 but we will eventually meet several other kinds of statements as well.
22 statements are executed in sequence,
24 We can, however, modify that sequence by using
25 <dfn>control flow constructs
</dfn>
27 arrange that a statement or group of statements
28 is executed only if some condition is true or false,
29 or executed over and over again to form a
<dfn>loop
</dfn>.
30 (A somewhat different kind of control flow happens when we call a function:
31 execution of the caller is suspended while the called function proceeds.
32 We'll discuss functions in
35 </p><p>My definitions of the terms
<dfn>statement
</dfn> and
36 <dfn>control flow
</dfn> are somewhat circular.
37 A statement is an element within a program which you can apply
39 control flow is how you specify the order in which the
40 statements in your program are executed.
41 (A weaker definition of a statement might be
42 ``a part of your program that does something,''
43 but this definition could as easily be applied to
46 </p><p><a href=
"sx3a.html" rel=subdocument
>3.1 Expression Statements
</a></p>
47 <p><a href=
"sx3b.html" rel=subdocument
>3.2 <TT>if
</TT> Statements
</a></p>
48 <p><a href=
"sx3c.html" rel=subdocument
>3.3 Boolean Expressions
</a></p>
49 <p><a href=
"sx3d.html" rel=subdocument
>3.4 <TT>while
</TT> Loops
</a></p>
50 <p><a href=
"sx3e.html" rel=subdocument
>3.5 <TT>for
</TT> Loops
</a></p>
51 <p><a href=
"sx3f.html" rel=subdocument
>3.6 <TT>break
</TT> and
<TT>continue
</TT></a></p>
55 <a href=
"sx2g.html" rev=precedes
>prev
</a>
56 <a href=
"sx3a.html" rel=precedes
>next
</a>
57 <a href=
"top.html" rev=subdocument
>up
</a>
58 <a href=
"top.html">top
</a>
61 This page by
<a href=
"http://www.eskimo.com/~scs/">Steve Summit
</a>
62 //
<a href=
"copyright.html">Copyright
</a> 1995,
1996
63 //
<a href=
"mailto:scs@eskimo.com">mail feedback
</a>