Control Statements


Control statements in the C programming language are constructs which allow you to conditionally execute pieces of code, based on whether a condition is true or false.

The most basic C control statement is the if statement. The C programming language has many different control statements, including if-else, if-elseif-else, while, for, and switch.

Off-by-1 Errors

A common mistake is to get the bounds of a looping control statement wrong by 1 (i.e. the loop executes one too less, or one too many times).