Incomplete Conditional Statement (if
)
If you don’t have to do anything in the
else
block (for example: “if there is ice cream on sale, buy ice cream”, but if not?), then the block
else
can be omitted and the incomplete form of the conditional statement can be used.
General view of the incomplete conditional operator
if ( condition ) // header if...else statement
{
... // block "if" - operators that are executed,
// if the condition in the header is true
}
How the Incomplete Conditional Statement Works (if
)
If the condition is true |
If the condition is false |
|
|
If the logical condition after the if is true , then
- the code inside {} after if is executed |
If the logical condition after the if is false , then
- the code inside {} after if is skipped |