What are the differences between precedence and associativity?

1 answer

Answer

1096724

2026-03-25 12:50

+ Follow

Precedence rules specify priority of operators (which operators will be evaluated first, e.g. multiplication has higher precedence than addition, PEMDAS).

The associativity rules tell how the operators of same precedence are grouped. Arithmetic operators are left-associative, but the assignment is right associative (e.g. a = b = c will be evaluated as b = c, a = b).

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.