+ 5
Iresult=a%b%c%d;
If int a=10,b=8,c=6,d=5, then what's the result of Iresult? Please explain it too.
3 odpowiedzi
+ 4
Thank you so much guys
+ 3
From left to right
10 % 8 % 6 % 5
2 % 6 % 5 (10 % 8 = 2)
2 % 5 (2 % 6 = 2)
2
+ 2
Since there are no other operators used except % (modulo division), there's no need to go for precedence.. All you have to check here is the associativity..
Here, it is LEFT ------> RIGHT
So, 10%8 = 2
2%6 = 2
2%5 = 2
On a whole, it goes smthg like this (((10%8)%6)%5) which results in "2"