Question: Consider the following two program fragments: Fragment 1: found:= false; counter:= 1; while (counter < n) and (not found) do if table[counter] = element then
Consider the following two program fragments:
Fragment 1:
found:= false; counter:= 1;
while (counter < n) and (not found)
do if table[counter] = element then found:= true end;
counter:= counter + 1 end;
if found then writeln (”found”) else writeln (”not found”) end;
Fragment 2:
found:= false; counter:= 1;
while (counter < n) and (not found)
do found:= table[counter] = element;
counter:= counter + 1 end;
if found then writeln (”found”) else writeln (”not found”) end;
Can the same test set be used if we wish to achieve a 100% branch coverage for both fragments?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
