Absolutly NOT. It depends on the relationships to any 'else' statements.sai rama krishna wrote:is it always good idea to put one additional if statement as in code snippet 2 than compressing code in one if statement as in code snippet 1?
The answer would be more obvious if you knew which test(s) failed.sai rama krishna wrote:why below code snippet 1 fails some tests
sai rama krishna wrote:I am trying one of codingbat problem
I am trying one codinbat problem. get some tests fail with below code
But below code pass all tests
What is difference between above two code snippets. To my eyes they look same except separate if statement in second code snippet?
Out on HF and heard nobody, but didn't call CQ? Nobody heard you either. 73 de N7GH
I'm saying the 'else-if' should NEVER have been called in the first place which is how your corrected code behaved.sai rama krishna wrote:This call posNeg(-1, 1, true)
else if((a<=0 && b>=0) || (b<=0 && a>=0) ){
else if( ( T && T ) || ( F && F ) ) {
You mean above should be as below right as -1 is T case and 1 is F case?
else if( ( T && T ) || ( F && T ) ) {
sai rama krishna wrote:which are arg1 and arg2 and arg3 ?
arg1 you mean negative
arg2 you mean a<=0
arg3 you mean b<=0
Out on HF and heard nobody, but didn't call CQ? Nobody heard you either. 73 de N7GH
Don't get me started about those stupid light bulbs. |