Topic: IF statements
- another basic element of programming
February 4,
2016
IF -- THEN -- ELSE(optional) -- ENDIF is one of the fundamental elements of programming.
When the IF comparison is true, the program does the instructions between the THEN and the ELSE and continues after the END IF.
When the IF comparison is false, the program does the instructions between the ELSE and the END IF and continues after the END IF.
ELSE is optional. When the ELSE is missing and the IF condition is false, the program just continues after the END IF, doing nothing.
IF -- THEN -- ELSE(optional) -- ENDIF is included in almost every programming language, possibly with slightly different syntax.
IF's and WHILE's may be nested inside each other without restriction. Programmers normally indent nested IF's and WHILE's.
IF's and WHILE loops are very similar, except the code inside the IF is executed once at the most, and possibly not at all.