Exam CTFL All QuestionsBrowse all questions from this exam
Question 7

Consider the following pseudo code

1. Begin

2. Read Gender

3. __Print "Dear"

4. If Gender = female

5. Print ("Ms")

6. Else

7. __Print ( "Mr")

8. Endif

9. End

How many test cases are needed to achieve 100 per cent decision coverage?

    Correct Answer: B

    To achieve 100 per cent decision coverage, we need to test all possible outcomes of every decision point in the code. In this pseudo code, there is one decision point (the if-else statement that checks if the gender is female). Therefore, we need two test cases: one where Gender is female (to cover the 'if' branch and print 'Ms') and one where Gender is male (to cover the 'else' branch and print 'Mr'). These two test cases will ensure that both branches of the decision are tested, achieving 100% decision coverage.

Discussion
subwaysandwichOption: B

Ans: B. Decision coverage = minimum number of test cases to cover all branches. In this case, there is only one if-else statement, which means that 2 test cases are required. Note that if they asked for 100% statement coverage, it would still be 2, because the "Dear" statement would be covered by both test cases.

Arcino12Option: C

1. Verify that "Dear" is displayed 2. Verify that "Ms." is displayed if gender is Female 3. Verify that "Mr." is displayed if gender is Male

laraerfOption: B

B is correct

Shoxybee99

what is the statement coverage here guys?

SivajiTheBossOption: B

Tip: un nested : 2 testcases (irrespective of count of If)

subwaysandwichOption: C

Ans: C. 3 tests are needed to check for "Dear", "Ms." and "Mr."

subwaysandwich

Please ignore this. I have revised my answer to B. See my other comment.