Mega Code Archive

 
Categories / C Tutorial / Statement
 

Break statement stops evaluating any further case statements

#include <stdio.h> main(){   int iResponse = 0;   printf("\nPlease select a category (1-4): ");   scanf("%d", &iResponse);   switch (iResponse) {     case 1:       printf("\nYou selected 1\n");       break;     case 2:       printf("You selected 2\n");       break;     case 3:       printf("You selected 3\n");       break;     case 4:       printf("You selected 4\n");       break;   } } Please select a category (1-4): 2 You selected 2