Chapter Summary

The if statement uses a test condition to control whether a program executes the single simple statement or block following the test condition. Execution occurs if the test expression has a nonzero value and doesn't occur if the value is zero. The if else statement enables you to select from two alternatives. If the test condition is nonzero, the statement before the else is executed. If the test expression evaluates to zero, the statement following the else is executed. By using another if statement to immediately follow the else, you can set up a structure that chooses between a series of alternatives.

The test condition is often a relational expression, that is, an expression formed by using one of the relational operators ...

Get C Primer Plus®, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.