Concept Flow - Why conditional flow control is needed
Start
Check Condition
Do A
End
The program checks a condition and chooses one path to follow, either 'Yes' or 'No', to decide what to do next.
int age = 20; if (age >= 18) { Console.WriteLine("Adult"); } else { Console.WriteLine("Minor"); }
| Step | Condition (age >= 18) | Result | Branch Taken | Output |
|---|---|---|---|---|
| 1 | 20 >= 18 | True | If block | "Adult" printed |
| 2 | N/A | N/A | End | Program ends |
| Variable | Start | After Step 1 | Final |
|---|---|---|---|
| age | 20 | 20 | 20 |
Conditional flow lets a program choose between paths.
Syntax: if (condition) { do A } else { do B }
If condition true, do A; else do B.
This controls program decisions step-by-step.