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: 
```
c = a++;

```

`a++` means return the value of `a` and increment the value of `a` so

```
c = 21;/* Because a = 21 before incrementing */

```

`a--` means the same return the value and decrement so

```
c = 22;

```

When we are at the line `c = a--`

`a` is `22` because of the previous `a++` operation after this line `a` will be decremented and `a` will be 21.

Yes since you are assigning the value to `c` the value of `a` is returned to it before `++` or `--`
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