Decrement Operators in C – Pre Decrement and Post Decrement Operators with Examples



In our previous article, We have discussed the Increment Operators in the C language. In today’s article, We are going to look into the Decrement operators in C language and different types of decrement operators in C programming language.

Decrement Operator in C Language :

  • The Decrement operators  Decrements the Value of the variable by 1 (by Subtracting 1 from it’s Current Value).
  • Decrement Operator is Unary operator. That means Decrement operator operates on only one Operand.
  • Decrement Operator have Highest priority than all Binary Operators. Because it is unary operator and Unary operators have higher priority than all Binary operators. You can see Full priority table here C operators Priority table.
  • Decrement Operator can not work on Constants. it can be apply only on Variables.
  • Decrement Operator Denoted by -- Symbol.
  • Ex : --X (pre decrement)  or X-- (Post Decrement).

Different Types of Decrement operators :

We have two types of Decrement operators those are

  1. pre-Decrement operator (or) prefix decrement operator.
  2. post-Decrement operator (or) postfix decrement operator.

Pre-decrement Operator :

  • In pre-decrement operator, Operator is written before the operand.
  • Pre-decrement operator decrements the value of variable first, then decremented value is used to evaluate the Expression.


In the above example, the variable y value will be 4. because a value is first decremented then it will assigned to variable y. so y value is 4.

Post-Decrement Operator :

  • In post-decrement operator, Operator is written after the Operand.
  • Post-decrement operator first expression is Evaluated and then value of Variable is decremented. that means decremented value is not used in expression.


In the example, The variable y value is 5. Because in post decrement operation the value of variable assigned first and then value of a will be Decremented. So the resulting value of y is 5. Also, the value of variable a after above expression is 4.

In the post-decrement operation, First Assignment happens then the decrement operation.

Example program 1 : C program to Understand decrement operators:

Program Output:

Example 2 : program to understand Decrement Operator in C:


Example 3 : Decrement Operator can not be used on Constants:


So it is clear that we can not use constants in decrement operators.

Also Read :


Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

4 Responses

  1. […] Decrements Operators and Pre and post decrements […]

  2. […] Decrements Operators and Pre and post decrements […]

  3. […] Decrement the end index – end– […]

  4. […] the character at the index endis a white space, Then decrement the endby 1 – i.e […]

Leave a Reply