if ( expression ) {
// block of code
}
if the expression is TRUE → execute the block of code, otherwise skip the block
if ( expression ) {
// block of code
}
else {
// block of code
}
if the expression is TRUE → execute the block of code with respect to if, otherwise → execute the block of code with respect to else.
if ( expression ) {
// block of code
}
else if ( expression ) {
// block of code
}
else if ( expression ) {
// block of code
}
else {
// block of code
}
if the expression is TRUE → execute the block of code with respect to if, otherwise → if the next expression is TRUE → execute the block of code with respect to the corresponding else if, otherwise → execute the block of code with respect to else.
switch( integer_expression* ) {
case constant_expression_1:
// line_statment;
// line_statment;
break;
case constant_expression_2:
// line_statment;
// line_statment;
break;
default:
// line_statment;
// line_statment;
break;
}
* can be a char_expression