- If statement in C is known as a decision-making statement.
- It makes a decision based on the condition given.
- It is followed by an optional else statement.
- The block of codes inside the if statement is executed only if the given condition is true.
- Codes inside the curly braces are skipped if the condition evaluates to false, and the code after the if statements are executed.
- Code inside parenthesis of the if statement is true, everything within the curly braces is executed.
- If condition true evaluates to true, code runs the printf execution.
Syntax
Sample Code
Output
if..else statements
- In an ..else statement, code inside the brackets is executed only if the statement condition evaluates to true.
- If the condition in the if statement evaluates to false, the code inside the else statement is executed.