GATE 2015 CS (CS3) – Question 58
Program X and the control-flow diagrams of Y and sequential composition Z are shown. Give their McCabe cyclomatic complexities in order.

Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (A) 4,4,7
Explanation
X has three decision constructs under the source convention: the first if, the while condition, and the final if. Thus M(X)=4; its compound while condition is treated as one predicate. Y has three independent back/branch choices, giving M(Y)=4 by E−N+2. Sequential composition shares one base path, so M(Z)=4+4−1=7. Hence A.