Tampilkan postingan dengan label structure selection. Tampilkan semua postingan
Tampilkan postingan dengan label structure selection. Tampilkan semua postingan

Minggu, 17 Maret 2013

Another way to create a branching is to use
switch keyword. By using a switch we can do
branching with diverse requirements.

Shape switch,

switch (switch_expression) {
case_selection1 case:
statement1; / / block 1
break;
case_selection2 case:
statement1; / / block 2
break;
default:
statement1; / / block n
break;
}

Posted by Kiki Risky | File under : , ,
Statement on else part of the if-else block can be another if else structure. Such structures allow us to make the selection more complex requirements.

Forms of if-else if,

if (boolean_expression1)
statement1;
else if (boolean_expression2)
statement2;

If-else structure is used when we want to execute a statement with a condition statement true and others false conditions.

The form of the if-else,

if (boolean_expression)
statement;
else
statement;




For more than one line,

Structure determines if a statement (or a block statement) that
will be executed if and only if the requirements of boolean (boolean statement) is true.

Shape if the first line of the statement,

if (boolean_expression)
statement;

 

The form if more than one line statement,

if (boolean_expression) {
statement1;
statement2;
}