Compound Statements

The if statement allows for compound statements, that is, more than one after the if part of the construct and also after the else. To do this a programmer must use an opening and closing bracket around the code. If the brackets are missed out or mismatched the program will not work as intended.

if (Boolean Expression)

{ // begin if

Program Statement(s)

} // end if


{ // begin else

Program Statement(s)

} ; // end else

Next: Multiple Conditions