Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > b38d2da330d1936e5ab1307c039c4941 > files > 505

octave-doc-3.6.4-3.mga4.noarch.rpm

<html lang="en">
<head>
<title>The continue Statement - GNU Octave</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GNU Octave">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Statements.html#Statements" title="Statements">
<link rel="prev" href="The-break-Statement.html#The-break-Statement" title="The break Statement">
<link rel="next" href="The-unwind_005fprotect-Statement.html#The-unwind_005fprotect-Statement" title="The unwind_protect Statement">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="The-continue-Statement"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="The-unwind_005fprotect-Statement.html#The-unwind_005fprotect-Statement">The unwind_protect Statement</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="The-break-Statement.html#The-break-Statement">The break Statement</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Statements.html#Statements">Statements</a>
<hr>
</div>

<h3 class="section">10.7 The continue Statement</h3>

<p><a name="index-g_t_0040code_007bcontinue_007d-statement-708"></a>
The <code>continue</code> statement, like <code>break</code>, is used only inside
<code>for</code> or <code>while</code> loops.  It skips over the rest of the loop
body, causing the next cycle around the loop to begin immediately. 
Contrast this with <code>break</code>, which jumps out of the loop altogether. 
Here is an example:

<pre class="example">     # print elements of a vector of random
     # integers that are even.
     
     # first, create a row vector of 10 random
     # integers with values between 0 and 100:
     
     vec = round (rand (1, 10) * 100);
     
     # print what we're interested in:
     
     for x = vec
       if (rem (x, 2) != 0)
         continue;
       endif
       printf ("%d\n", x);
     endfor
</pre>
   <p>If one of the elements of <var>vec</var> is an odd number, this example skips
the print statement for that element, and continues back to the first
statement in the loop.

   <p>This is not a practical example of the <code>continue</code> statement, but it
should give you a clear understanding of how it works.  Normally, one
would probably write the loop like this:

<pre class="example">     for x = vec
       if (rem (x, 2) == 0)
         printf ("%d\n", x);
       endif
     endfor
</pre>
   </body></html>