how to skip the case in switch

Posted by Santosh198318 under C# on 12/8/2011 | Points: 10 | Views : 1774 | Status : [Member] | Replies : 1
how to skip the one case statement in switch and continue the remaining..
i have the 5 cases in switch ..in that based on the one condition am skipping the one case statement (using goto)its executing fine ..but after end of the case..its coming the whatever i skip the case statement ..am getting confusion please help me in this scenario...




Responses

Posted by: BhupendarSingh on: 12/8/2011 [Member] Starter | Points: 25

Up
0
Down
Hello Santosh198318,
/**
** This example contains a switch statement that performs
** the same statement for more than one case label.
**/

#include <stdio.h>

int main(void)
{
int month;

/* Read in a month value */
printf("Enter month: ");
scanf("%d", &month);

/* Tell what season it falls into */
switch (month)
{
case 12:
case 1:
case 2:
printf("month %d is a winter month\n", month);
break;

case 3:
case 4:
case 5:
printf("month %d is a spring month\n", month);
break;

case 6:
case 7:
case 8:
printf("month %d is a summer month\n", month);
break;

case 9:
case 10:
case 11:
printf("month %d is a fall month\n", month);
break;

case 66:
case 99:
default:
printf("month %d is not a valid month\n", month);
}

return(0);
}

For more details please check out this link...
http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8l.doc%2Flanguage%2Fref%2Fssits.htm

It might resolve your problem.

Bhupendar Singh

Santosh198318, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response