[Solved] Why doesn’t ++ increment integer value?


Because the expression

num1++

evaluates to num1.


You may want to do:

++num1

which evaluates to num1 + 1.


Note however that both expressions increment num1 by one.

Evaluating num1 in the next statement evalutes to the incremented value.


In short

In C, why doesn’t num1++ increment in the printf()?

num1++ does increment num1 but it evaluates to num1 and that evaluation is what you are passing to printf().

15

solved Why doesn’t ++ increment integer value?