EXAMPLE OF DECISION STATENENTS
EXAMPLE OF DECISION STATENENTS
It checks
the given
condition
and then
executes
its
sub-block.
The
decision
statement
decides the statement to be executed
after the success or failure of a given
condition.
Types:
- 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
-
StatementSyntaxIf statementif(condition) Statement;If-else statementIf (condition)
{
Statement 1;
Statement 2;
}
else
{
Statement 3;
Statement 4;
}Nested if-else statementIf (condition){
-
Statement 1;Statement 2;}Else if (condition){Statement 3;Statement 4;}Else{Statement 5;Statement 6;}Break statementBreak;Continue statementContinue;Goto statementgoto label;Switch() statementSwitch (variable or expression){Case constant A: Statement; Break;Case constant B: Statement; Break;Default: Statement;}
- 9 LOOP CONTROL STATENENTS
Loop
is a block of statements which are repeatedly executed for certain
number of times.
Types
- For loop
- Nested for loops
- While loop
- do while loop
- do-while statement with while loop
-
StatementSyntaxFor loopFor(initialize counter; test condition; re-evaluation parameter){Statement;Statement;}Nested for loopfor(initialize counter; test condition; re-evaluation parameter){Statement;Statement;for(initialize counter; test condition; re-evaluation parameter) Statement;Statement;}}While loopWhile (test condition){Body of the loop}Do while loopdo{Statement;}While(condition);Do-while with while loopDo while(condition){Statement;}While (condition);
No comments
Post a Comment