CONDITIONALS
IF
if(i == 1)
puts("1");
* the braces {} are optional when there's only one statementIF/ELSE
if(i == 1)
puts("1");
else if(i == 2)
puts("2");
else if(i == 3)
puts("3");
else
puts("Others");
* the braces {} are optional when there's only one statementSWITCH
switch(i) {
case 1:
puts("Only one?"); break;
case 2:
puts("I want more."); break;
case 3:
puts("Not bad."); break;
case 4:
puts("Okay.");
}
* A break statement terminates the execution of the nearest
enclosing switch or the nearest enclosing loop. The execution
resumes with the statement present next to the terminated switch
statement or the terminated loopLast updated