Exam CTFL All QuestionsBrowse all questions from this exam
Question 83

How many test cases are necessary to cover all the possible sequences of statements (paths) for the following program fragment?

Assume that the two conditions are independent of each other : -if (Condition 1)then statement 1else statement 2if (Condition 2)then statement 3

    Correct Answer: C

    To cover all possible sequences of statements (paths) in the given program fragment, we need to consider all possible combinations of the conditions and their outcomes. There are two independent conditions which can each be either true or false. Hence, there are 2^2 = 4 different combinations possible: (Condition 1 true, Condition 2 true), (Condition 1 true, Condition 2 false), (Condition 1 false, Condition 2 true), and (Condition 1 false, Condition 2 false). Therefore, 4 test cases are necessary.

Discussion
MadjamOption: C

#tip nested condition SC=1+no.of ifs's