0
what is the priority order of mathematical operators in C++?
2 Respuestas
+ 2
in most cases it's just left to write. so if we type
3 / 4 * 5, we'll get 0 (assuming we're using ints)
5 * 4 / 3, we'll get 6.
primarily the rule of thumb I follow is no more than 3 calculations in one line. however if we use parentheses those calculations are done before others interact with it. so let's say we have
3 / 4 * 5, and we want to make sure we always get 4 * 5 first, we should instead write 3 / (4*5), same as on math
+ 2
The operator precedence of C++ is the standard mathematical precedence, where % has the same precedence as /.