CTFL Exam QuestionsBrowse all questions from this exam

CTFL Exam - Question 11


Consider the following pseudo code:

1. Begin

2. Input X, Y

3. If X > Y

4. __Print (X, is greater than, Y)

5. Else

6. __Print (Y, is greater than or equal to, X)

7. EndIf

8. End

What is the minimum number of test cases required to guarantee both 100% statement coverage and 100% decision coverage?

Show Answer
Correct Answer: B

In the given pseudocode, to achieve 100% statement coverage and 100% decision coverage, we need to ensure that every line of the code and every branch of the decision is executed at least once. We need to test both paths of the decision (i.e., when X > Y and when X <= Y). This can be done with 2 test cases, one where X is greater than Y and one where X is less than or equal to Y. Hence, the minimum number of test cases required to guarantee both 100% statement coverage and 100% decision coverage is 2.

Discussion

4 comments
Sign in to comment
69pawan6969Option: C
Nov 3, 2022

I believe C is more appropriate

Prasanth25
Dec 20, 2021

Should we treat reading 2 variables are 2 statements?

MthethoOption: D
Feb 17, 2023

D. Statement coverage = 2, Decision coverage = 1

laraerfOption: C
Jun 8, 2023

C is correct