In certain situations, it is necessary to execute instructions within a program only under certain conditions. Alternative structures (also known as decision structures) allow handling such situations.
The if statement is the most commonly used alternative structure.
if( Expression )
Statement1
else
Statement2
if( Expression )
Statement1
if(Expression) …
if(Expression != 0) …
Similarly, the following sequences are equivalent:
if(!Expression) …
if(Expression == 0) …
In this section you can generate a summary of the page content using AI! Feel free to use the button below whenever you are in a hurry and don't have time to learn everything!
In this section you can ask our expert robot anything related to the questions you encountered during the lessons! Feel free to use the button below whenever you need additional explanations!