Thursday, May 2, 2019

Expression evaluation


In c language expression evaluation is mainly depends on priority and associativity.

Priority

This represents the evaluation of expression starts from "what" operator.

Associativity

It represents which operator should be evaluated first if an expression is containing more than one operator with same priority.
OperatorPriorityAssociativity
{}, (), []1Left to right
++, --, !2Right to left
*, /, %3Left to right
+, -4Left to right
<, <=, >, >=, ==, !=5Left to right
&&6Left to right
||7Left to right
?:8Right to left
=, +=, -=, *=, /=, %=9Right to left

Example 1:

images

Example 2:

images

No comments:

Post a Comment

Why learning C Programming is a must?

C is a procedural programming language. It was initially developed by Dennis Ritchie between 1969 and 1973. It was mainly developed as...