Nearby lessons

22 of 72

C - Increment and Decrement Operators

Increment and Decrement Operators is one of the foundational topics in C programming. This lesson explains Increment and Decrement Operators (++ --), Program 1: pre-increment vs post-increment and Program 2: pre-decrement vs post-decrement with complete, runnable code examples, clear step-by-step explanations, and common mistakes to avoid with exam-style MCQs at the end.

Increment and Decrement Operators (++ --)

  • ++ increases a variable by 1 (increment).
  • decreases a variable by 1 (decrement).
  • Pre form (++a) — increase first, then use the value.
  • Post form (a++) — use the value first, then increase.
Trainer's Note: Memory trick: pre = prefix, so it acts first. post = after, so it acts last. Read a++ as "use a, then add 1" and ++a as "add 1, then use a". The two programs below show exactly this.

Program 1: pre-increment vs post-increment

Example02
Loading editor…

Program 2: pre-decrement vs post-decrement

Example03
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.