Definition Selection
Syntax = if, if else(2 atau lebih boolean), nested IF, dan switch case.
IF
Syntax :
if (boolean expression) statement;
or
if(boolean expression){
statement 1;
statement 2;
….
}
IF ELSE
Syntax :
if (boolean expression) statement1;
else statement 2;
or
if(boolean expression){
statement 1;
statement 2;
else{
statement 3;
statement 4;
…
}
*Switch-case
-tidak sekompleks if
-contohnya digunakan untung menghitung huruf konsonan
-Syntax:
switch(expression){
case constant:statement 1;
break;
case constant:statement 2;
break;
default:statements;
}
*?:Operator
syntax :
condition?then-expression
:else-expression
if(a>b)
max_value=a;
else
max_value=b;
as
max_value=(a>b)
?a:b;
ERROR TYPE
1.) Compile-Time Error = caused by syntax error.
2.) Link-Time Error = caused by no object code at link time.
3.) Run-Time Error = successfully compiled but error at runtime.
4.) Logical Error = program is successful but the logic is wrong.