Decision Control Statements in C Language
The Decision statement checks the given condition and then executes its sub-block. The decision statement determines the information be performed after the True or False of a given situation.
Types of decision statements:
- If statement
- If-else statement
- Nested if-else statement
- Break statement
- Continue statement
- Goto statement
- Switch() statement
- Nested switch ()case
- Switch() case and Nested if
Statement | Syntax |
If statement | if(condition) statement; |
If-else statement | If (condition) |
{ | |
Statement 1; | |
Statement 2; | |
} | |
else | |
{ | |
Statement 3; | |
Statement 4; | |
} | |
Nested if-else statement | If (condition) |
{ | |
Statement 1; | |
Statement 2; | |
} | |
Else if (condition) | |
{ | |
Statement 3; | |
Statement 4; | |
} | |
Else | |
{ | |
Statement 5; | |
Statement 6; | |
} | |
Break statement | Break; |
Continue statement | Continue; |
Goto statement | goto label; |
Switch() statement | Switch (variable or expression) |
{ | |
Case constant A: | |
Statement; | |
Break; | |
Case constant B: | |
Statement; | |
Break; | |
Default: | |
Statement; | |
} |
LOOP CONTROL STATEMENTS
The loop control statements in C are used to perform looping operations until the given condition is true. Once the state is false, the control loop exits the information.
Types
- For loop
- Nested for loops
- While loop
- do-while loop
- do-while statement with a while loop
Statement | Syntax |
For loop | For(initialize counter; test condition; re-evaluation parameter) { Statement; Statement; } |
Nested for loop | for(initialize counter; test condition; re-evaluation parameter) { Statement; Statement; for (initialize counter; test condition; re-evaluation parameter) Statement; Statement; } } |
While loop | While (test condition) { Body of the loop } |
Do while loop | do { Statement; } While(condition); |
Do-while with while loop | Do while(condition) { Statement; } While (condition); |