int main() {
int i=1;
i=++i + i++;
std::cout<<i<<std::endl;
return 0;
}
here the output is 5
int main() {
int i=1;
i=i++ + i++ + i++;
std::cout<<i<<std::endl;
return 0;
}
here the output is 6
in the first code if we ignore the last increment we get 4 which is wrong but in the second code if we ignore the last increment we get 6 which is right.
both codes have post increment at the end of the equation
New contributor
user24743039 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1