Jump to content

can anyone answer for this ?


chicagoil

Recommended Posts


Int Test ( int j)
{
j = j-1;                          // this should be  j= j+1 but the programmer accidently has put -1
j = j/30000;
return j;
}


The line j=j-1;  is incorrect in this function.
Function Test accepts an integer j, subtracts one from it, divides it by 30000 (integer division, result is the whole number no remainder) and returns the value just computed.
Integers are implemented by using 16 bits in this computer executing this program/function, as result the lowest possible input value is -32,768 and the highest one is 32,767.
Thus there are 65,356 possible inputs into this program.
Will we create and run all 65,536 test cases to test this program?
If not, which input values we would choose that would be able to detect this bug?

Input (j)
Expected Result
Actual Result
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...