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?
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?
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; }
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)