Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have managed to put the body below the actual loop, as far as the code is concerned.</p> <p>You have:</p> <pre><code>do { } while (criteria); { // code you want to execute repeatedly } </code></pre> <p>As a result, you get the error message for your <code>break</code> statement because it is not, in fact, contained within a loop.</p> <p>You should only have:</p> <pre><code>while (criteria) { // code you want to execute repeatedly } </code></pre> <p>Omit to <code>do</code> portion, as that actually creates a legal loop above the code you really <em>want</em> to loop.</p> <p><strong>Edit:</strong> @Randy, this is the second time you've posted a similar question. You are effectively trying to combine the <code>do</code> and the <code>while</code> loops. Go to <a href="http://msdn.microsoft.com/en-us/library/32dbftby.aspx" rel="nofollow noreferrer">MSDN and review loops</a>. In short, a <code>while</code> loop checks the condition before the loop body, the <code>do</code> loop checks after the loop body. The <code>do</code> loop also uses the <code>while</code> keyword, and that may be confusing you.</p> <p>The <strong>Do</strong> loop</p> <pre><code>do { // your code... // this loop is useful when you want the loop to execute at least once, since // the exit condition will be evaluated *after* the first iteration } while (condition); </code></pre> <p>The <strong>While</strong> loop</p> <pre><code>while (condition) { // your code... // this loop is useful when you want to prevent *any* iterations unless the // original boolean condition is met. } </code></pre> <p>These are two seperate looping constructs. Combining them does not double your looping fun, it simply creates a single loop (the <code>do</code>) and then another block of code that follows.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload