Post Increment / Decrement in C

February 12, 2025 3 Comments » Hits : 250





Post-Increment :  y = a ++
Steps :

  1. Value of a is assigned to y
  2. Then value of a is incremented

In Short :

  • When Postfix (++/-) is used with a variable in an Expression ,The Expression is evaluated first using the original value of variable and then variable is incremented/decremented by one 
  • Here a is incremented /decremented after use

Live Example :
#include<stdio.h>void main(){int a,b,x=10,y=10;a = x++;b = ++y;printf("Value of a : %d",a);printf("Value of b : %d",b);}

Output :

Value of a : 10Value of b : 11

Why Output is 10 in case of Post-increment : 

  1. Post (after) , Value of x is first assigned to a
  2. Then x is Incremented

    Incoming search terms:

    • tyang

      I have a question while studying C.
      what is the different when I use i++, and when I use ++i to make an increament.

      tyang

    • Admin

      i++ is called as "Post" increment i.e y = a++ then firstly current value of 'a' is assigned to y and then 'a' gets incremented ….

    • A.karthick

      i can't the concept postincrement and postdecrement and preincrement and postdecrement