CTFL Exam QuestionsBrowse all questions from this exam

CTFL 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

Show Answer
Correct Answer: AC

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

1 comment
Sign in to comment
MadjamOption: C
Dec 13, 2021

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