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 5846639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:36:18+00:00 2026-05-22T12:36:18+00:00

For example lets consider the following 2 codes: for (i = 0; i <

  • 0

For example lets consider the following 2 codes:

for (i = 0; i < 1000; i++)
{
   if ( i % 2 != 0)
   {
       continue;
   }
   else
   {
     ...  
   }    
}

and

for (i = 0; i < 1000; i++)
{
   if (i % 2 == 0)
   {
     ...  
   }    
}

Both will lead to the same result. So which one to use? Which one is better? Are there any significant performance differences between the two? Lets see what you guys see about this. I like the discussions I see here about these things. This may lead to better code writing and better execution times. I posted this question because I did not find the answer to it. I may post another one like this in the future if I did not find an answer to it.

P.S. Whats the purpose of using continue inside a loop when you can go without it?

  • 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-22T12:36:20+00:00Added an answer on May 22, 2026 at 12:36 pm

    In this specific example? There’s no purpose in using continue whatsoever.

    As you mentioned, both code samples produce exactly the same results. And neither will be detectably faster than the other.

    The decision you make of which one to prefer should be based on readability and clarity, rather than some type of misguided “optimization” attempt. With that in mind, the second is far clearer. I’d seriously question the programming chops of someone who used the first in a real codebase.

    As a basic guideline, never use an if-else when a single if will do. In this case, you’re comparing != and then finding the opposite of that with an else statement—that’s almost like saying !(!=), which produces a double-negative. Very hard to read or understand. In general, you should try to evaluate positive conditions in an if statement, rather than negative ones, to prevent precisely this.

    And there’s really no reason to post additional questions that are similar to this one. All of the answers will be the same. Ignore any possible performance difference (if one even exists, which is quite unlikely, given an optimizing compiler), and focus on which version makes the most sense to you as a human being who has to read it. Please ignore anyone who gives you advice to the contrary.

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

Sidebar

Related Questions

My simplified and contrived example is the following:- Lets say that I want to
How does one read a data file in an iPhone project? For example, lets
Let's consider following, simplified example: We have 2 tabs withing <rich:tabPanel switchType=ajax> , each
Let's consider the following XML Schema: <?xml version=1.0 encoding=UTF-8?> <schema targetNamespace=http://www.example.org/library elementFormDefault=qualified xmlns=http://www.w3.org/2001/XMLSchema xmlns:lib=http://www.example.org/library>
Here is my scenario. For the example lets say that I need to return
Lets say I am currently at: http://example.com/folder/page.html Is it possible to create a relative
As an example, lets say I wanted to list the frequency of each letter
This is a contrived example, but lets say I have declared objects: CustomObj fooObj;
DataGridView, for example, lets you do this: DataGridView dgv = ...; DataGridViewCell cell =
If I was to send a URL to a DNS server, lets say: dev.example.com/?username=daniel,

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.