DamnSchool
The switch statement is used to pickup or execute a particular group of statements from several available group of statements. It allows us to make a decision from the number of choices.

It is a multiway decision statement, it tests the value of given variable or expression against a list of case values and when a match is found, a block of statements associated with that case is executed.

Switch statement

#include<stdio.h>
void main()
{
int a=1;
switch(a)
{
case 1:
printf("case is 1");
break;
case 2:
printf("case is 2");
break;
default:
printf("default");
break;
}
}

Run Example >

< Previous Next >

Privacy Policy Terms of Service About
Creative Commons License
This work is licensed under a Creative Commons Attribution-NoDerivatives 4.0 International License.