Thread: newbies question

  1. #1
    Registered User
    Join Date
    Jan 2015
    Posts
    3

    newbies question

    i am reading a book about c for engineers and in the chapter for switch does not have an example or a mention how i can have a case with 2 or 3 nbrs i mean
    switch(a)
    {
    case(1)(2): ...

    statements

    break;
    case(3):..........
    can someone help me?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You would typically make use of fall through, e.g.,
    Code:
    switch (a)
    {
    case 1:
    case 2:
        statement;
        break;
    case 3:
    case 4:
    case 5:
        statement;
        break;
    default:
        statement;
    }
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. For Newbies Like Me
    By oval in forum C# Programming
    Replies: 0
    Last Post: 03-26-2006, 02:55 AM
  2. Question. 4 Newbies 4all time
    By lifeisendless4m in forum C Programming
    Replies: 14
    Last Post: 10-07-2004, 12:19 PM
  3. Something for the Newbies..
    By ExDigit in forum Windows Programming
    Replies: 0
    Last Post: 01-06-2002, 07:42 AM
  4. Question (i Speak For All Newbies)
    By Leeman_s in forum Game Programming
    Replies: 8
    Last Post: 10-31-2001, 10:02 PM
  5. Newbies question about the integer type
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 10-17-2001, 08:09 PM