Possible Duplicates:
What is more efficient i++ or ++i?
How do we explain the result of the expression (++x)+(++x)+(++x)?
Difference between i++ and ++i in a loop?
Hi I am trying these two programs
void fun(){
int k=0;
int i=10;
k = (i++)+(++i);
cout<<k<<endl;
}
Output = 22 as i++ will give 10 and ++i will evaluate into 12
but
void fun(){
int k=0;
int i=10;
k = (++i)+(++i);
cout<<k<<endl;
}
Output = 24
It should be 23 I guess or there is sth that I am not able to see
Thanks in advance