~ubuntu-branches/debian/sid/octave3.0/sid

« back to all changes in this revision

Viewing changes to doc/interpreter/HTML/The-continue-Statement.html

  • Committer: Bazaar Package Importer
  • Author(s): Rafael Laboissiere
  • Date: 2007-12-23 16:04:15 UTC
  • Revision ID: james.westby@ubuntu.com-20071223160415-n4gk468dihy22e9v
Tags: upstream-3.0.0
ImportĀ upstreamĀ versionĀ 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html lang="en">
 
2
<head>
 
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; } 
 
23
--></style>
 
24
</head>
 
25
<body>
 
26
<div class="node">
 
27
<p>
 
28
<a name="The-continue-Statement"></a>
 
29
Next:&nbsp;<a rel="next" accesskey="n" href="The-unwind_005fprotect-Statement.html#The-unwind_005fprotect-Statement">The unwind_protect Statement</a>,
 
30
Previous:&nbsp;<a rel="previous" accesskey="p" href="The-break-Statement.html#The-break-Statement">The break Statement</a>,
 
31
Up:&nbsp;<a rel="up" accesskey="u" href="Statements.html#Statements">Statements</a>
 
32
<hr>
 
33
</div>
 
34
 
 
35
<h3 class="section">10.7 The <code>continue</code> Statement</h3>
 
36
 
 
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. 
 
42
Here is an example:
 
43
 
 
44
<pre class="example">     # print elements of a vector of random
 
45
     # integers that are even.
 
46
     
 
47
     # first, create a row vector of 10 random
 
48
     # integers with values between 0 and 100:
 
49
     
 
50
     vec = round (rand (1, 10) * 100);
 
51
     
 
52
     # print what we're interested in:
 
53
     
 
54
     for x = vec
 
55
       if (rem (x, 2) != 0)
 
56
         continue;
 
57
       endif
 
58
       printf ("%d\n", x);
 
59
     endfor
 
60
</pre>
 
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.
 
64
 
 
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:
 
68
 
 
69
<pre class="example">     for x = vec
 
70
       if (rem (x, 2) == 0)
 
71
         printf ("%d\n", x);
 
72
       endif
 
73
     endfor
 
74
</pre>
 
75
   </body></html>
 
76