Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5939125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:46:55+00:00 2026-05-22T15:46:55+00:00

Wondering what a continue statement does in a do…while(false) loop, I mocked up a

  • 0

Wondering what a continue statement does in a do...while(false) loop, I mocked up a simple test-case (pseudo-code):

count = 0;
do {
    output(count);
    count++;
    if (count < 10)
        continue;
}while (false);

output('out of loop');

The output was, to my surprise:

0
out of loop

A bit confused, I changed the loop from a do...while to a for:

for (count = 0; count == 0; count++) {
    output(count);
    if (count < 10)
        continue;
}
output('out of loop');

While functionally not the same, the purpose is practically the same: Make a condition only satisfied the first iteration, and in next ones continue (until a certain value is reached, purely for stopping possible infinite-loops.) They might not run the same amount of times, but functionality here isn’t the important bit.

The output was the same as before:

0
out of loop

Now, put into terms of a simple while loop:

count = 0;
while (count == 0) {
    output(count);
    count++;
    if (count < 10)
        continue;
}
output('out of loop');

Once again, same output.

This is a bit confusing, as I’ve always thought of the continue statement as “jump to the next iteration”. So, here I ask: What does a continue statement do in each of these loops? Does it just jump to the condition?

((For what it’s worth, I tested the above in JavaScript, but I believe it’s language-agnostic…js had to get at least that right))

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:46:56+00:00Added an answer on May 22, 2026 at 3:46 pm

    In a for loop, continue runs the 3rd expression of the for statement (usually used as some kind of iteration), then the condition (2nd expression), and then the loop if the condition is true. It does not run the rest of the current iteration of the loop.

    In a while (or do-while) loop, it just runs the condition and then the loop if the condition holds. It also does not run the rest of the current iteration of the loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a piece of code that has a loop within a try statement.
Just wondering if a .NET app can be compiled down to native machine code
If I have a statement in Ruby that I want to continue on the
http://www.research.att.com/~njas/sequences/A097196 I was wondering how to continue generating the sequence given in the link.
I am wondering if I should continue to learn OCaml or switch to F#
I was just wondering how i would let my java program continue running, but
I'm thinking of upgrading my iPhone 3G and was wondering if I can continue
Sometimes a labeled break or continue can make code a lot more readable. OUTERLOOP:
I am wondering if you have good ways to show plots inside a loop
just wondering which approach would be better if both blocks of code would yield

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.