Consider the following code fragment and then answer the que
Consider the following code fragment, and then answer the questions below.
if (i > j) {
printf(\"%d is greater than %d.\ \", i, j);
} else {
printf(\"%d is smaller than %d.\ \", i, j);
}
(a) Describe three tests that you would perform on this block of code to maximize the chance of discovering any bugs. In other words, what values for i and j would you try? You can assume i and j are integers.
(b) Assume that you test with the test cases you specified in part (a). Consider what output would be produced by the code above for each test case. Describe one modification you would make to the code as a result of your testing.
Solution
a)
case 1:
give non integer values for i and j
eg:i=5.5,j=10.4
case 2:
give very big integer value for i and j
eg:i=111111111111111,j=999999999999999999999
case 3
give value zero for i and j
i=0,j=0 .output will be 0 is smaller than 0 which is not rrue
2)
in case 1 only the integer part will be evaluated.so result will be 5 is smaller than 10
in case 2 it will not have enough merory to allocate.so we will get a warning message like integer overflow or message like integer constant is too large for its type
in case 3
