Nearby lessons

24 of 72

C - Operator Precedence

Operator Precedence is one of the foundational topics in C programming. This lesson explains Operator Precedence — What Runs First with complete, runnable code examples, clear step-by-step explanations, and common mistakes to avoid with exam-style MCQs at the end.

Operator Precedence — What Runs First

When an expression has many operators, C follows a fixed priority order. The higher-precedence operator runs first. See it live in one program:

Example01
Loading editor…

Operator Precedence — What Runs First

Trainer's Note: Trainer tip: never rely on memory for precedence. When in doubt, use brackets `( )` — they make your intention clear and avoid bugs. a + (b * c) is easier to read than hoping C does the right thing.
Example02
Loading editor…
📝 Key Takeaways
  • Operators: arithmetic (+ - * / %), relational (== != < > <= >=), logical (&& || !), assignment (= += -= *= /= %=), ++ --, ternary ?:.
  • Each operator family has its own complete program — copy and run one at a time.
  • Integer division drops decimals: 5/2 = 2; use 5.0/2 for 2.5.
  • % gives the remainder and works only on integers.
  • a++ uses then increases; ++a increases then uses.
  • Ternary: condition ? value1 : value2.
  • Use brackets to control the order of evaluation.

🧠 Test Your Knowledge

1 Questions
Progress: 0 / 1

Finished this lesson?

Mark it as complete to track your progress and see technology completion stats.