3
<title>The continue Statement - Untitled</title>
4
<meta http-equiv="Content-Type" content="text/html">
5
<meta name="description" content="Untitled">
6
<meta name="generator" content="makeinfo 4.11">
7
<link title="Top" rel="start" href="index.html#Top">
8
<link rel="up" href="Statements.html#Statements" title="Statements">
9
<link rel="prev" href="The-break-Statement.html#The-break-Statement" title="The break Statement">
10
<link rel="next" href="The-unwind_005fprotect-Statement.html#The-unwind_005fprotect-Statement" title="The unwind_protect Statement">
11
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12
<meta http-equiv="Content-Style-Type" content="text/css">
13
<style type="text/css"><!--
14
pre.display { font-family:inherit }
15
pre.format { font-family:inherit }
16
pre.smalldisplay { font-family:inherit; font-size:smaller }
17
pre.smallformat { font-family:inherit; font-size:smaller }
18
pre.smallexample { font-size:smaller }
19
pre.smalllisp { font-size:smaller }
20
span.sc { font-variant:small-caps }
21
span.roman { font-family:serif; font-weight:normal; }
22
span.sansserif { font-family:sans-serif; font-weight:normal; }
28
<a name="The-continue-Statement"></a>
29
Next: <a rel="next" accesskey="n" href="The-unwind_005fprotect-Statement.html#The-unwind_005fprotect-Statement">The unwind_protect Statement</a>,
30
Previous: <a rel="previous" accesskey="p" href="The-break-Statement.html#The-break-Statement">The break Statement</a>,
31
Up: <a rel="up" accesskey="u" href="Statements.html#Statements">Statements</a>
35
<h3 class="section">10.7 The <code>continue</code> Statement</h3>
37
<p><a name="index-g_t_0040code_007bcontinue_007d-statement-550"></a>
38
The <code>continue</code> statement, like <code>break</code>, is used only inside
39
<code>for</code> or <code>while</code> loops. It skips over the rest of the loop
40
body, causing the next cycle around the loop to begin immediately.
41
Contrast this with <code>break</code>, which jumps out of the loop altogether.
44
<pre class="example"> # print elements of a vector of random
45
# integers that are even.
47
# first, create a row vector of 10 random
48
# integers with values between 0 and 100:
50
vec = round (rand (1, 10) * 100);
52
# print what we're interested in:
61
<p>If one of the elements of <var>vec</var> is an odd number, this example skips
62
the print statement for that element, and continues back to the first
63
statement in the loop.
65
<p>This is not a practical example of the <code>continue</code> statement, but it
66
should give you a clear understanding of how it works. Normally, one
67
would probably write the loop like this:
69
<pre class="example"> for x = vec