by R4R Team

-Switch in C language is a conditional statement that are used to execute the code according to the conditions.

Syntax-
switch(variable)
{
case value1:
body;
case value2:
body;
.
.
.
.
}


program-

#include< stdio.h>
int main()
{
int a;
printf("Enter Number\n");
scanf("%d",&a);
switch(a)
{
case 1:
printf("case 1 is execute\n");
case 2:
printf("case 2 is execute\n");
}
print("After Switch");
}


output-

Enter Number
2
case 2 is execute

-In this program, We take a input of the integer number then check the different case in switch statement.
-It execute the case on the basis of the variable value.




Leave a Comment: