How if in C works?
The working of the if statement in C is as follows:
- STEP 1: When the program control comes to the if statement, the test expression is evaluated.
- STEP 2A: If the condition is true, the statements inside the if block are executed.
- STEP 2B: If the expression is false, the statements inside the if body are not executed.
- STEP 3: Program control moves out of the if block and the code after the if block is executed.
C – if Statement
The if in C is the most simple decision-making statement. It consists of the test condition and if block or body. If the given condition is true only then the if block will be executed.