Make decisions in your code by executing blocks based on one or more conditions.
The `if-else` statement is the most fundamental decision-making construct in C. It allows a program to execute a specific block of code only if a particular condition is true, and optionally, a different block of code if the condition is false. The basic syntax starts with the `if` keyword, followed by a condition in parentheses. If this condition evaluates to a non-zero value (true), the code block immediately following it is executed. If the condition is zero (false), the block is skipped. You can provide an alternative path using the `else` keyword. The code block following `else` is executed only when the `if` condition is false. This creates a simple two-way branch. For handling more than two possibilities, you can use the `else if` ladder. This allows you to chain multiple conditions together. The program checks the first `if` condition. If it's false, it proceeds to the `else if` condition and checks it. This continues down the chain until a true condition is found, and its corresponding block is executed. Once a block is executed, the rest of the `else if` and `else` blocks in the chain are skipped. A final `else` block can be added at the end to serve as a default case, which runs if none of the preceding `if` or `else if` conditions are met. This structure is incredibly versatile and forms the basis for most logical operations in programming, enabling your code to respond differently to varying inputs and states.