Hi there,
I am getting different result for the above program. Could you pleaselet me know how did you get 42.0? That will solve many confusions.
Thanks
K Palaniswamy
Your statement:
"4 + 5 * 6 / 3" will be treated as "4 + (5 * (6 / 3))"
The above is wrong. It will be treated as 4 + ((5 * 6) / 3) and the answer is 14.
Your evaluation will also produce the answer 14 but the precedence you used is wrong. You just got lucky that the grouping resulting in the same answer :)
operatorsrakesh August 26, 2011 at 12:45 PM
class x{ public static void main(String args[]){ int a=5,b=10,c=15; System.out.println("(a+=(b+c)):"+(a+=(b+c))); } } //please send the output
Getting Different Result for the above programKarthikeyan Palaniswamy September 27, 2011 at 9:46 PM
Hi there, I am getting different result for the above program. Could you pleaselet me know how did you get 42.0? That will solve many confusions. Thanks K Palaniswamy
dbtNatarajan November 3, 2011 at 10:32 AM
hi i tried ur exp but i am getting o/p 54. calculated manually
Wrong descriptionziggy November 13, 2011 at 8:20 PM
Your statement: "4 + 5 * 6 / 3" will be treated as "4 + (5 * (6 / 3))" The above is wrong. It will be treated as 4 + ((5 * 6) / 3) and the answer is 14. Your evaluation will also produce the answer 14 but the precedence you used is wrong. You just got lucky that the grouping resulting in the same answer :)
incorrect evaluationabc January 11, 2012 at 9:13 PM
multiplication is carried out first try 4+5*7/3, you will know the difference
Post your Comment