chicagoil Posted October 15, 2010 Report Share Posted October 15, 2010 Int Test ( int j) {j = j-1; // this should be j= j+1 but the programmer accidently has put -1j = 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 ResultActual Result Quote Link to comment Share on other sites More sharing options...
chanti local Posted October 15, 2010 Report Share Posted October 15, 2010 29999 coz we assume te result to be 1 but comes something else... Quote Link to comment Share on other sites More sharing options...
chicagoil Posted October 15, 2010 Author Report Share Posted October 15, 2010 thank you but i need step by step , in detail. Its my interview question. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.