CSS Computer Science (Optional) — Paper-I, Section-A, Topic II subtopic. The three ways instructions can flow through a program.
| Structure | Flowchart Shape(s) | Pseudocode Form |
|---|---|---|
| Sequence | Rectangles connected top-to-bottom by plain arrows, no branching | step1 |
step2 |
||
step3 |
||
| Selection (if-else) | Diamond (the test), with two outgoing arrows labelled Yes/No leading to separate rectangles | IF cond THEN ... ELSE ... ENDIF |
| Iteration (loop) | Diamond (the test) with a rectangle for the body, and an arrow looping back from the body to the diamond | WHILE cond DO ... ENDWHILE |
If-else flowchart (textual): Decision: cond? (diamond) → Yes → Statement A (rectangle) → join | No → Statement B (rectangle) → join
While-loop flowchart (textual): Decision: cond? (diamond) → Yes → Loop body (rectangle) → arrow back up to the Decision | No → exit the loop, continue after it
Do-while flowchart (textual): Loop body (rectangle) runs first → Decision: cond? (diamond) → Yes → arrow back up to the body | No → exit — note the body sits before the diamond, which is exactly why it always runs at least once.
if: executes a block only if a condition is trueif-else: executes one block if true, another if falseelse if ladder: chains multiple conditions checked in orderswitch-case: selects one branch among many based on the value of an expressionswitch (grade) {
case 'A': printf("Excellent"); break;
case 'B': printf("Good"); break;
default: printf("Needs improvement");
}
break, execution falls through to the next case regardless of its label — a classic exam trapdefault is optional and can appear anywhere, but conventionally goes last| Loop | Condition Check | Minimum Executions | Typical Use |
|---|---|---|---|
| for | Before each iteration | 0 | Known/fixed number of iterations |
| while | Before each iteration (pre-test) | 0 | Unknown iteration count, condition-driven |
| do-while | After each iteration (post-test) | 1 | Body must run at least once (e.g. menus) |
for (int i = 0; i < 5; i++) { ... } // init; condition; update
while (n > 0) { ... } // checks BEFORE running body
do { ... } while (n > 0); // checks AFTER running body — runs at least once