+ 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.

15th Jun 2021, 4:18 PM
Anshika
3 odpowiedzi
+ 4
Thank you so much guys
16th Jun 2021, 12:32 PM
Anshika
+ 3
From left to right 10 % 8 % 6 % 5 2 % 6 % 5 (10 % 8 = 2) 2 % 5 (2 % 6 = 2) 2
15th Jun 2021, 4:26 PM
TOLUENE
TOLUENE - avatar
+ 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"
15th Jun 2021, 4:28 PM
sarada lakshmi
sarada lakshmi - avatar