Shorthand operator is giving different result
i=i-j and i-=j both are giving different results. Why this is happening?
R_N Can you describe the purpose and goal of the code, briefly? and which line(s) were troubling you? I was actually expecting a saved code link, so we can refer to line numbers easily. Raw text code doesn't have line numbers obviously. (Edit) Some examples for input may also help ...
For the sake of clarity, please share the code's link 👍
It result same. May you have doing something wrongly.. Chech again..
https://code.sololearn.com/cb644x1w1r03/?ref=app It's not possible. both will give same. NOTE - suppose a variable hold a number 5 if you do like this int num = 10; num -= 3; //Now the value of num changed System.out.println(num);// now num is 7 num = num - 3; //Now num is 7 not 10 and after it the num changes System.out.println(num); OUTPUT WILL BE - 7 4 These are different maybe this is your mistake .
R_N In the 2nd expressions of instruction I = i -el-1 ; it's short form is i -= (el+1) You may using i -= (el-1).
R_N No. Am getting same output.. Add what input you are giving and what you getting as output?
Jayakrishna🇮🇳 Check for the input 1 2 3 2 5 7 9 11 13 Using shorthand operator the answer is 33 And normal assignment (i = i-el) is giving 20
Jayakrishna🇮🇳 Thanks! You are right. Got the answer.
I have a problem that i can't solve alone anyone to help
shortHand just & just is meant to compile cods faster.
Hi Can i talk to you