Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

NPTEL Online Certification Courses

Indian Institute of Technology Kharagpur

Software Engineering
Assignment-11
TYPE OF QUESTION: MCQ/MSQ
Number of questions: 10 Total mark: 10 X 1 = 10

For each of the following questions one or more of the given options are correct. Choose the
correct options.

QUESTION 1:
Which one of the following is an indicative measure of the white box testing difficulty of a program?
a. Number of statements in the program
b. Number of decision statements in the program
c. Complexity of the arithmetic expressions used in the program
d. Time complexity of the program
e. Number of functions in the program
Correct Answer: b. Number of decision statements in the program
Detailed Solution:

Number of decision statements (if-else, loops, switch cases) helps to determine the white-box testing
difficulty of a program.

QUESTION 2:
Which of the following subsumption relations are incorrect?
a. Multiple condition coverage subsumes decision coverage
b. Basic condition coverage subsumes decision coverage
c. Basic condition coverage subsumes statement coverage
d. Modified Condition/ Decision Coverage (MC/DC) subsumes basic condition coverage
e. Path coverage subsumes multiple condition coverage

Correct Answer: b. Basic condition coverage subsumes decision coverage


e. Path coverage subsumes multiple condition coverage
Detailed Solution:
Basic condition coverage subsumes decision coverage and path coverage subsumes multiple
condition coverage are not correct.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

Questions 3 to 7 are based on the following “C” code segment.


int main (){
int a, b=0;
scanf(“%d”,&a);
if( a < 1 || a>1000) {
b=b+20;}
if( a == 20 ){
b=b+30;}
if( a == 30 ){
b=b+40;}
else{
b=b+100; }
}

QUESTION 3:
At least how many test cases are needed for achieving decision coverage on the given C code?
a. 3
b. 4
c. 5
d. 6
e. 8
Correct Answer: a. 3

Detailed Solution:
In decision coverage, the whole decision is executed as True and False at least once. With 3 test cases,
we can achieve 100% decision coverage: a=20, a=30, a=0.

QUESTION 4:
At least how many test cases are needed for the given C code for achieving basic condition coverage?
a. 3
b. 4
c. 5
d. 6
e. 7
Correct Answer: b. 4

Detailed Solution:
For first decision, two condition required to check: one test case for a<1 and another test case for
a>1000. For, second decision, one condition a==20 required to check so one test case. Similarly, for
third decision, one condition a==30 required to check so one test case. So, total four test cases required
for achieving basic condition coverage.
The test cases are:- TC1: a=20, TC2: a=30, TC3: a=0, TC4: a=1005
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

QUESTION 5:
At least how many test cases are needed for the given C code for achieving multiple condition coverage?
a. 4
b. 6
c. 8
d. 9
e. Multiple condition coverage is not achievable for the given code
Correct Answer: e. Multiple condition coverage is not achievable for the given code

Detailed Solution:
It is not possible to make both the condition true for a single test case in the first decision of the
program. For example, if we take a=0 then a<1 become true but a>1000 is not true. Similarly, if we
take a=1100 then a>1000 become true but a<1 become false. So, for a same test case we cannot
achieve ‘TT’ for both the condition. So, that is the reason for not achievable multiple condition
coverage for the given code.

QUESTION 6:
At least how many test cases are needed for the given C code for achieving MC/DC coverage?
a. 3
b. 4
c. 5
d. 7
e. MC/DC coverage is not achievable for the given code
Correct Answer: b. 4

Detailed Solution:
The number of test cases can be found as N + 1, where N represents the number of basic
conditions. First decision consist of two condition. So, for those two condition 2+1=3 test cases
required. Now, we left with other two condition a==20 and a==30. For checking first two condition
(a<1, a>1005), if we take a=20, then it will also check the condition a==20 or if we take a=30, then it
will also check the condition a==30. So, with first two condition we can check also either a==20 or
a==30. But, with first two condition if we check a==20 then a==30 will left or if we check a==30, then
a==20 will left. So, with 3 test cases, we required another test case to check the remaining one
condition. So total 3+1 = 4 test cases required.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

QUESTION 7:
At least how many test cases are needed for the given C code for achieving basis path coverage?
a. 4
b. 6
c. 8
d. 9
e. Basis path coverage is not achievable for the given code
Correct Answer: a. 4

Detailed Solution:
The number of minimum test cases required for achieving basis path coverage can be easily found by
the formula N+1. Here N = bounded area. From the above program, we can find that N=3, so the
number of test cases required is 4.

QUESTION 8:
If two code segments have Cyclomatic complexities of N1 and N2 respectively, what will be the Cyclomatic
complexity of the juxtaposition of the two code segments?
a. N1+N2
b. N1+N2+1
c. N1+N2-1
d. N1*N2
e. N1*N2 + 1
Correct Answer: c. N1+N2-1
Detailed Solution:
It is a standard result. The proof is beyond the scope of the course.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

QUESTION 9:
Consider the following conditional statement. At least how many test cases are necessary for
condition/decision coverage?
if((a>=0) or (a<=100)) a=a-1;
a. 1
b. 2
c. 3
d. 4
e. Condition/decision coverage is not achievable

Correct Answer: e. Condition/decision coverage is not achievable


Detailed Solution:
NO test cases cam make the decision false. So, Condition/decision coverage is not achievable.

QUESTION 10:
Consider the following conditional statement. At least how many test cases are necessary for multiple
condition coverage?
if((a>=0) or (b<=c)) a=a-1;
a. 1
b. 2
c. 3
d. 4
e. Multiple condition coverage is not achievable

Correct Answer: d. 4
Detailed Solution:
Here, 2 independent conditions. So, No. of MCC = 2^2 = 4.

************END***********

You might also like