1 <!DOCTYPE HTML PUBLIC
"-//W3O//DTD W3 HTML 2.0//EN">
2 <!-- This collection of hypertext pages is Copyright 1995-7 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>Statements
</title>
10 <link href=
"sx14b.html" rev=precedes
>
11 <link href=
"sx14d.html" rel=precedes
>
12 <link href=
"sx14.html" rev=subdocument
>
17 <p>The
<TT>switch
</TT> statement allows you to jump to one of a
18 number of numeric
<TT>case
</TT> labels depending on the value of
20 it's more convenient than a long
<TT>if
</TT>/
<TT>else
</TT> chain.
21 (However, you can use
<TT>switch
</TT>
22 only when the expression is integral
23 and all of the
<TT>case
</TT> labels are compile-time constants.)
24 </p><p>The
<TT>do
</TT>/
<TT>while
</TT> loop
25 is a loop that tests its controlling expression
26 at the bottom of the loop,
27 so that the body of the loop always executes once
28 even if the condition is initially false.
29 (C's
<TT>do
</TT>/
<TT>while
</TT> loop is therefore like
30 Pascal's
<TT>repeat
</TT>/
<TT>until
</TT> loop,
33 C's
<TT>while
</TT> loop is like Pascal's
<TT>while
</TT>/
<TT>do
</TT> loop.)
35 when you really need to write ``spaghetti code,''
36 C does have the all-purpose
<TT>goto
</TT> statement,
41 <a href=
"sx14b.html" rev=precedes
>prev
</a>
42 <a href=
"sx14d.html" rel=precedes
>next
</a>
43 <a href=
"sx14.html" rev=subdocument
>up
</a>
44 <a href=
"top.html">top
</a>
47 This page by
<a href=
"http://www.eskimo.com/~scs/">Steve Summit
</a>
48 //
<a href=
"copyright.html">Copyright
</a> 1995-
1997
49 //
<a href=
"mailto:scs@eskimo.com">mail feedback
</a>