The GATE Grind

GATE 2015 CS (CS3) – Question 58

Software Engineering · Modular Software Design · 2 marks · Multiple choice

Program X and the control-flow diagrams of Y and sequential composition Z are shown. Give their McCabe cyclomatic complexities in order.

Diagram for GATE 2015 CS (CS3) question 58
  1. 4,4,7
  2. 3,4,7
  3. 4,4,8
  4. 4,3,8

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.

More Modular Software Design questions

All Modular Software Design questions →