Mar 5, 2014 at 1:50am UTC
how do you solve this problem?
I did it like this
int b = 4 , p =5, r =2, v=8;
double x= 10.2
B=10-v%p*2;
i did 10 - 8 % 5 * 2 and got the answer b=8
did i do this correctly? i did multiplication before modulo or do i do modulo first?
Mar 5, 2014 at 2:17am UTC
What are you trying to do?
Mar 5, 2014 at 2:33am UTC
B= 10- v % p*2;
is what im trying to solve with the above values
that are given to me
what do i do first multiply or modulo?
Mar 5, 2014 at 2:56am UTC
so modulo goes first? even though multiplication is first in the operator precedence it goes */%... on that site
Mar 5, 2014 at 3:05am UTC
Multiplication, division, and modulo (* / % ) have the same precedence, and they get evaluated left-to-right, so the v % p goes first because you wrote that first.
When in doubt, use parentheses.
Last edited on Mar 5, 2014 at 3:06am UTC