I stumbled upon a question about arithmetic precedence in a test and I cannot wrap my head at all around its answer.
float x = 5 % 3 * + 2 - 4.5 / 5 * 2 + 2;
My "understanding" right now is that multiplication must take place first before division and modulus, yet when I try using that approach, the answer is 6.55 instead of 4.20. I tried playing around with the expression (adding brackets here and there), and it turns out that 5 % 3 takes place first before everything else. I just don't understand why since, according to the precedence table I was provided, that shouldn't be the case. Could someone clear this up for me?
you can refers this link for more detail http://www.difranco.net/compsci/C_Operator_Precedence_Table.htm