A5 - decision making

if else block

if (expression1) {
	/* statements to be executed
	if the expression1 is evaluated true */
} else if (expression2) {
	/* statements to be executed
	if the expression2 is evaluated true */
} else {
	/* statements to be executed
	if the expressions are all false */
}

logical operators

operator description
&& and
|| or
! not

switch statement

switch(n) {
case value1:
	/* statement for case 1 */
	break;
case value2:
	/* statement for case 2 */
	break;
default:
	/* statement for all other cases */
	break;
}

ternary conditional operator

maxnumber = (num1 > num2) ? num1 : num2; /* (expression) ?, output if true :output of false