retagged by
685 views
3 votes
3 votes

The following program is to be tested for statement coverage: 

begin 
if(a==b){S1;exit;} 
else if (c==d){S2;} 
else{S3;exit;} 
S4; 
end 

The test cases $T1,T2,T3$ and $T4$ given below are expressed in terms of the properties satisfied by the values of variables $a,b,c$ and $d$. The exact values are not given.

$T1:a,b,c$ and $d$ are all equal 
$T1:a,b,c$ and $d$ are all distinct 
$T3:a=b$ and $c!=d$ 
$T4:a!=b$ and $c=d$ 

Which of the test suites given below ensures coverage of statements $S1,S2,S3$ and $S4$?

  1. $T_1,T_2,T_3$
  2. $T_2,T_4$
  3. $T_3,T_4$
  4. $T_1,T_2,T_4$
retagged by

1 Answer

2 votes
2 votes

Option D 

T1 cover statement S1

because all are equal means a==b true so  only S1 execute and then exit program

 

T2 cover statement S3 

because all are distinct means statement a==b false then c==d false so only  statement S3 execute and then exit program

 

T4 cover statement S2,S4 

given a!=b so statement a==b false means note execute 

given c=d means statement c==d true so S2 execute and here program not exit so  S4 will  be execute also

Answer:

Related questions

2 votes
2 votes
2 answers
2
admin asked Mar 30, 2020
1,082 views
Output of following program#include<stdio.h int main() { int i=5; printf("%d %d %d", i++,i++,i++); return 0; }$7\:6\:5$$5\:6\:7$$7\:7\:7$Compiler Dependent
3 votes
3 votes
1 answer
3
admin asked Mar 30, 2020
1,758 views
Output of following program? #include<stdio.h void dynamic(int s,...) { printf("%d",s); } int main() { dynamic(2,4,6,8); dynamic(3,6,9); return 0; }$2\:3$Compiler Error$4...