Exam CTFL All QuestionsBrowse all questions from this exam
Question 80

Consider the following pseudo code:

1 Begin

2 Read Time

3 If Time < 12 Then

4 Print(Time, "am")

5 Endif

6 If Time > 12 Then

7 Print(Time 12, "pm")

8 Endif

9 If Time = 12 Then

10 Print (Time, "noon")

11 Endif

12 End

If the test cases Time = 11 and Time = 15 were input, what level of decision coverage would be achieved?

    Correct Answer: D

    For decision coverage, each possible outcome of every decision must be exercised at least once. The pseudo code contains three decisions: Time < 12, Time > 12, and Time = 12. For the test case Time = 11, the outcomes are True for Time < 12, and False for both Time > 12 and Time = 12. For the test case Time = 15, the outcomes are False for Time < 12, True for Time > 12, and False for Time = 12. Thus, the True outcomes for Time < 12 and Time > 12, and the False outcomes for all three decisions (Time < 12, Time > 12, Time = 12) are covered, giving us 5 out of 6 possible decision outcomes. Therefore, the decision coverage is 83% or 5/6.

Discussion
NJAOption: C

I think 4/6 is correct C.

NangoOption: D

can someone please explain why the answer is D?