Question: In the following program

```
     main()
 {
     int a = 21;
     int b = 10;
     int c ;
     c = a++; 
     printf("Value of c is %d\n", c );
     c = a--; 
     printf("Value of c is %d\n", c );
 }

```

the output is 

```
Value of c is 21
Value of c is 22

```

if we write just a++ it shows 22 and if we write a-- it shows 20 whereas when it is assigned to c as above it shows as 21 and 22 , why so?

Answer: 
In case of a++, ++ is a postfix operator.
So first value of a is assigned to c and then a is incremented.Hence value of c is 21.

Now the current value of a is 22.
In case of c=a--, value of a(i.e 22 is assigned) to c and then a is decremented.
Hence value of c is 22.
There are `postfix` and `prefix` operators in C. When you use `postfix` operator then **assignment happens first then operation**. If you want to do assignment and operation in one line then you have to use `prefix` operator where **operation happens first then assignment**. If you modify your code as below then you will get expected output

```
     c = ++a; 
     printf("Value of c is %d\n", c );
     c = --a; 
     printf("Value of c is %d\n", c );

```

[This link](http://fresh2refresh.com/c/c-operators-expressions/c-increment-decrement-operators/) will give you more understanding