The GATE Grind

GATE 2010 CS (CS1) – Question 54

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

Choose the tests giving statement coverage of:

if (a==b) { S1; exit; }
else if (c==d) { S2; }
else { S3; exit; }
S4;

T1: a=b=c=d. T2: a,b,c,d all distinct. T3: a=b and c≠d. T4: a≠b and c=d.

  1. T1,T2,T3
  2. T2,T4
  3. T3,T4
  4. T1,T2,T4

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (D) T1,T2,T4

Explanation

S1 is reached by T1 or T3. S3 needs a≠b and c≠d, supplied by T2. S2 and the following S4 need a≠b,c=d, supplied by T4. Thus all three path types are necessary; among the options, T1,T2,T4 is the complete set, D.

More Modular Software Design questions

All Modular Software Design questions →