x=4+2%-8;
This gives output=6 Please anyone explain how?
x=4+2%-8; is equivalent to x = 4 + (2 % -8); which gives x = 4 + 2 which is 6.
More: C Operator Precedence Table
If you check this precedence chart first mod is taken and then added to 4
so (2%-8) gives 2
then 2+4 = 6
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With