Switch case is used for control statements which decides the execution of statements rather than if-else statements.In other word, Switch Case is utilized when there are several cases and each requires a different task to be completed.
Switch:
Switch statement is used as a control statement which allows the execution of multiple conditions for the multiple possible values of a single variable.
Break:
Break statement is used to stop the process or execution of code. It works as an exit statement.
Continue:
Continue statement is also known as the jump statement. It is used to skip a segment of code.
#include <stdio.h>
int main()
{
int a = 3;
switch (a) {
case 1:
printf("1");
break;
case 2:
printf("2");
break;
case 3:
printf("3");
break;
case 4:
printf("4");
break;
default:
printf("Other than 1, 2, 3 and 4");
break;
}
return 0;
}
Login/Signup to comment