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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:38:15+00:00 2026-05-10T18:38:15+00:00

Given a simple switch statement switch (int) { case 1 : { printf(1\n); break;

  • 0

Given a simple switch statement

switch (int) {     case 1 :     {         printf('1\n');         break;     }      case 2 :      {         printf('2\n');     }      case 3 :      {         printf('3\n');     } } 

The absence of a break statement in case 2, implies that execution will continue inside the code for case 3. This is not an accident; it was designed that way. Why was this decisions made? What benefit does this provide vs. having an automatic break semantic for the blocks? What was the rationale?

  • 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. 2026-05-10T18:38:16+00:00Added an answer on May 10, 2026 at 6:38 pm

    Many answers seem to focus on the ability to fall through as the reason for requiring the break statement.

    I believe it was simply a mistake, due largely because when C was designed there was not nearly as much experience with how these constructs would be used.

    Peter Van der Linden makes the case in his book ‘Expert C Programming’:

    We analyzed the Sun C compiler sources to see how often the default fall through was used. The Sun ANSI C compiler front end has 244 switch statements, each of which has an average of seven cases. Fall through occurs in just 3% of all these cases.

    In other words, the normal switch behavior is wrong 97% of the time. It’s not just in a compiler – on the contrary, where fall through was used in this analysis it was often for situations that occur more frequently in a compiler than in other software, for instance, when compiling operators that can have either one or two operands:

    switch (operator->num_of_operands) {     case 2: process_operand( operator->operand_2);               /* FALLTHRU */      case 1: process_operand( operator->operand_1);     break; } 

    Case fall through is so widely recognized as a defect that there’s even a special comment convention, shown above, that tells lint ‘this is really one of those 3% of cases where fall through was desired.’

    I think it was a good idea for C# to require an explicit jump statement at the end of each case block (while still allowing multiple case labels to be stacked – as long as there’s only a single block of statements). In C# you can still have one case fall through to another – you just have to make the fall thru explicit by jumping to the next case using a goto.

    It’s too bad Java didn’t take the opportunity to break from the C semantics.

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

Sidebar

Ask A Question

Stats

  • Questions 63k
  • Answers 63k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Table Item: ItemId Table Rating: UserId, ItemId1, ItemId2, WinnerId If… May 11, 2026 at 10:22 am
  • added an answer The common way of doing this is using a trigger… May 11, 2026 at 10:22 am
  • added an answer A simple method is to make the body 100% of… May 11, 2026 at 10:22 am

Related Questions

Given a simple switch statement switch (int) { case 1 : { printf(1\n); break;
Given a simple statement, such as: <statement id=SelectProducts resultMap=???> SELECT * FROM Products </statement>
Given a simple (id, description) table t1, such as id description -- ----------- 1
Given a relatively simple CSS: div { width: 150px; } <div> 12333-2333-233-23339392-332332323 </div> How
Given a couple of simple tables like so: create table R(foo text); create table
I am designing a simple internal framework for handling time series data. Given that
Does anyone know any simple way to retrieve the country from a given IP
Is there any simple way to generate a default crud (given an entity) with
This is a purely theoretical question. Given three simple classes: class Base { }
We were given a sample document, and need to be able to reproduce the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.