0
Please tell me where i made a mistake?
I want same output for both cases. public class Program { public static void main(String[] args) { int num1 = 4; int num2 = 28; num2/=num1+num2; // num2=(num2/num1)+(num2/num2); System.out.println(num2); } } Here output comes : 0 public class Program { public static void main(String[] args) { int num1 = 4; int num2 = 28; // num2/=num1+num2; num2=(num2/num1)+(num2/num2); System.out.println(num2); } } Output comes : 8
3 Answers
+ 5
"num2 /= num1 + num2;" ⥠"num2 = num2 / (num1 + num2);" ⢠"num2 = (num2 / num1) + (num2 / num2);"
+ 3
SauravK.__, yes. In my previous comment "âĄ" means "identical to" and "â˘" means "not identical to".
+ 1
you want to say:
num2/=num1+num2; != (num2/num1 + num2/num2);
that's why both cases have different output??