how to skip the case in switch

Posted by Santosh198318 under C# on 12/8/2011 | Points: 10 | Views : 1964 | Status : [Member] | Replies : 1
how to skip the one case statement in switch and continue the remaining..
i have the 5 cases in switch 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 getting confusion please help me in this scenario...


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

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);

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

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

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

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


For more details please check out this link...

It might resolve your problem.

Bhupendar Singh

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

Login to post response