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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:59:51+00:00 2026-05-16T00:59:51+00:00

I am interested if there is any difference from the C or C++ compiler

  • 0

I am interested if there is any difference from the C or C++ compiler perspective whether I use:

if (value == a) {
    ...
}
else if (value == b) { 
    ...
}
else if (value == c) { 
    ...
}

versus

switch (value) {
    case a:
        ...
        break;
    case b:
        ...
        break;
    case c:
        ...
        break;
}

It feels to me that there is no difference, just syntactic. Does anyone know more about it?

Thanks, Boda Cydo.

  • 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-16T00:59:52+00:00Added an answer on May 16, 2026 at 12:59 am

    There is a difference – with switch’es, the compiler may optimize the switch to use a lookup table. This may be possible if there are many values which are close enough to each other. For example, this switch:

    switch ( integer ) {
      case 10:
         xxx
         break;
      case 12:
         yyy
         break;
      case 13
         zzz
         break;
    }
    

    could become (pseudocode):

    address = lookup[ integer - 10 ]; // which is prefilled with { case_10, err, err, case_12, case 13 }
    goto address;
    case_10: xxx; goto err;
    case_12: yyy; goto err;
    case_13: zzz; 
    err: //do nothing
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Are there any good references for synchronisation algorithms? I'm interested in algorithms that synchronize
Are there any good source-code analyses tools for OSX. I am particularly interested in
I'm interested to know if there's any sites out there that has implemented CardSpace
I am interested if there is a port for the server implementation.
I'm interested if there are libraries in java, that render voxel -based sceneries? Open-Source
Is there anyone working solo and using fogbugz out there? I'm interested in personal
I'm interested in writing software that depends on being able to identify that there
I'm primarily interested in pgsql for this, but I was wondering if there is
Something I have always been interested in out of curiosity, is there a tool
There's a lot of interest these days in Erlang as a language for writing

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.