In c the operators *,/,% which has the higher priority? | Sololearn: Learn to code for FREE!

+5

# In c the operators *,/,% which has the higher priority?

3/15/2018 5:09:40 PM

Saranya

+10

* , / , % have same precedence ... so associativity plays all game in this case , associativity is from left to right , which means that if these are present together ... then the operator which comes first from the left will get executed first ... ie first * then / & the % in above case //hope it helps best to understand precedence & associativity for these operators

+6

for more information as my friends said above check that: http://en.cppreference.com/w/c/language/operator_precedence

+4

For what I know they have the same precedence. but in situations like the expression: 2 * 6 / 4 % 2 They are evaluated from left to right. So a step by step evaluation would do: step 1. (2 * 6) / 4 % 2 = 12 / 4 % 2 step 2. (12 / 4) % 2 = 3 % 2 step 3. 3 % 2 = 1 EDITED: and here is the code to prove: https://code.sololearn.com/cu7Db4WPkzne/?ref=app

0

en matematicas existe un orden operacional, en el que cuando no estan las parentesis, se sigue ese orden , ese orden es el mismo que sigue el orden aritmetico de los operadores , estudialo para que no sea tan confuso