What is the order of evaluation in C?

Precedence and associativity

Order of evaluation refers to the operator precedence and associativity rules according to which mathematical expressions are evaluated.

Same precedence

Operators in the same row have the same precedence. The compiler will evaluate them in any order.

It may choose another order when the same expression is evaluated again, but this will not affect the evaluated answer.

Different precedence

Operators in different rows have different precedence. Rows are in order of decreasing precedence. This means that below a given row, any operator in the lower rows will have lower precedence than the operators in the highest row.

Altering the order

The order of precedence can be altered by using parentheses around the parts of the mathematical expression that needs to be evaluated first.

Table of the order of evaluation

The order of evaluation in C is illustrated in the following figure:

#include <stdio.h>
int main() {
int answer_1 = 0; // stores order evaluated answer
int answer_2 = 0; // stores left to right evaluation
answer_1 = 2 * 3 + 4 / 2;
answer_2 = 2 * (3 + 4) / 2;
printf("Answer with order of evaluation: %d\n", answer_1);
printf("Answer without order of evaluation: %d\n", answer_2);
return 0;
}
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved