Cambridge O Level Computer Science · Syllabus 2210 · Programming
Nested Statement
What is Nested Statement?
A control structure written entirely inside the block of another control structure; the inner structure must open and close within the outer one, and candidates are not required to write more than three levels.
This definition is part of the Programming chapter in Cambridge O Level Computer Science.
Nested Statement in context
A statement is nested when it sits entirely inside the block of another statement. The four combinations you must handle are selection inside selection, selection inside iteration, iteration inside selection and iteration inside iteration. The syllabus states that candidates will not be required to write more than three levels of nested statements — so three is the ceiling for anything you produce, and if your answer is heading for four, the right move is to pull the inner part out into a procedure or function.
Common mistakes with Nested Statement
- M15. “The more deeply nested my solution, the more sophisticated it is.” TruthCandidates will not be required to write more than three levels of nested statements. Four levels signals an over-complicated design, not a clever one. FixMove the innermost block into a procedure or function, or replace a chain of nested IFs on one identifier with a flat CASE OF.

