Concept Flow - If statement
Start
Evaluate condition
Condition True?
No→Skip if block
Execute if block
Continue
End
The program checks a condition. If true, it runs the code inside the if block. Otherwise, it skips it and continues.
#include <stdio.h> int main() { int x = 5; if (x > 3) { printf("x is greater than 3\n"); } return 0; }
| Step | Condition | Result | Branch Taken | Output |
|---|---|---|---|---|
| 1 | x > 3 | True | Execute if block | x is greater than 3 |
| 2 | End of if | N/A | Continue |
| Variable | Start | After if | Final |
|---|---|---|---|
| x | 5 | 5 | 5 |
If statement syntax:
if (condition) {
// code runs if condition is true
}
Checks condition once.
Runs block only if true.
Skips block if false.