Between ++p & p++ , there is no diff in terms of speed of execution .because both are of unary . But there is a diff in the evaluation of an expression by using these unary operations.
++p - First the value of p gets incremented by one & then the incremented value will be used in the expression for further evaluation.
p++ - First the value of p is used in the expression & then the value of p will get incremented by one .
For eg :
a) p= 10;
val = ++p * 100 ;
Here val = 1100;
p = 11;
b) p=10;
val = p++ * 100;
Here val = 1000;
p =11;
- Jayalakshmi Kaja