Switch case in C language 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:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!