What Is a Nested “if” Statement?

A nested “if” statement is the true condition in a series of conditions in computer programming. It is used when multiple responses are possible and the outcome for each response is different.

An example of a nested “if” statement is the following: If the result is a number between three and five, print it in the color blue. If the result is a number less than three, print it in red. If the result is any other number, print it in green. Different computer languages have limits on the number of “if” statements that may be nested. Nested “if” statements are also called “if-then” or “if-else” statements.