0% found this document useful (0 votes)
34 views1 page

Operator Precedence

In C++, operator precedence determines the order of operator evaluation in expressions, while associativity defines the direction of evaluation for operators of the same precedence. Higher precedence operators are evaluated first, and associativity can be either left-to-right or right-to-left. The document also provides a table of operators along with their precedence and associativity rules.

Uploaded by

Sukhwinder Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views1 page

Operator Precedence

In C++, operator precedence determines the order of operator evaluation in expressions, while associativity defines the direction of evaluation for operators of the same precedence. Higher precedence operators are evaluated first, and associativity can be either left-to-right or right-to-left. The document also provides a table of operators along with their precedence and associativity rules.

Uploaded by

Sukhwinder Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

‭Operator Precedence and Associativity in C++‬

I‭n C++,‬‭operator precedence‬‭determines the order in which operators are evaluated in an‬
‭expression.‬‭Associativity‬‭defines the direction in which operators of the same precedence‬
‭are evaluated (either from left to right or right to left).‬

‭Operator Precedence:-‬‭When an expression contains multiple operators,‬‭precedence‬


‭ ecides which operator will be applied first. Operators with higher precedence are evaluated‬
d
‭before those with lower precedence.‬

‭Operator Associativity:-‬‭Associativity‬‭comes into play when multiple operators with the‬


s‭ ame precedence appear in an expression. It defines whether the evaluation happens from‬
‭left to right (left associativity) or right to left (right associativity).‬

‭OPERATORS‬ ‭OPERATORS PRECEDENCE‬ ‭ASSOCIATIVITY‬


‭( ) [] . ->‬ ‭LEFT--->RIGHT‬
‭- ++ -- ! size of(type)‬ ‭RIGHT--->LEFT‬
‭* / %‬ ‭LEFT--->RIGHT‬
‭+‬ ‭-‬ ‭LEFT--->RIGHT‬
‭< <= > >=‬ ‭LEFT--->RIGHT‬
‭== !=‬ ‭LEFT--->RIGHT‬
‭& &‬ ‭LEFT--->RIGHT‬
‭| |‬ ‭LEFT--->RIGHT‬
‭?:‬ ‭LEFT--->RIGHT‬
‭= += -= *= /= %=‬ ‭RIGHT--->LEFT‬
‭,‬ ‭LEFT--->RIGHT‬

You might also like