Breaking News

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:

      1. If statement
      2. If-else statement
      3. Nested if-else statement
      4. Break statement
      5. Continue statement
      6. Goto statement
      7. Switch() statement
      8. Nested switch ()case
      9. 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;
}

    1. 9 LOOP CONTROL STATENENTS
Loop is a block of statements which are repeatedly executed for certain number of times.

Types

      1. For loop
      2. Nested for loops
      3. While loop
      4. do while loop
      5. do-while statement with 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);

No comments