There are 4 types of Unconditional/Case Control Statements in C language. They are,
- switch
- break
- continue
- goto
1. SWITCH CASE STATEMENT IN C:
- Switch case statements are used to execute only specific case statements based on the switch expression.
- Below is the syntax for switch case statement.
switch (expression)
{
case label1: statements;
break;
case label2: statements;
break;
case label3: statements;
break;
default: statements;
break;
}
EXAMPLE PROGRAM FOR SWITCH..CASE STATEMENT IN C:
#include<stdio.h>
int main ()
{
int value = 3;
switch(value)
{
case 1:
printf(“Value is 1 \n” );
break;
case 2:
printf(“Value is 2 \n” );
break;
case 3:
printf(“Value is 3 \n” );
break;
case 4:
printf(“Value is 4 \n” );
break;
default:
printf(“Value is other than 1,2,3,4 \n” );
}
return 0;
}
OUTPUT:
| Value is 3 |
2. BREAK STATEMENT IN C:
- Break statement is used to terminate the while loops, switch case loops and for loops from the subsequent execution.
- Syntax: break;
3. CONTINUE STATEMENT IN C:
- Continue statement is used to continue the next iteration of for loop, while loop and do-while loops. So, the remaining statements are skipped within the loop for that particular iteration.
- Syntax : continue;
4. GOTO STATEMENT IN C:
- goto statements is used to transfer the normal flow of a program to the specified label in the program.
- Below is the syntax for goto statement in C.
{
…….
go to label;
…….
…….
LABEL:
statements;
}
