Here is a code
#include<stdio.h>
int main()
{
int i=5;
printf("%d%d",++i,++i);
}
I am not understand, why the output is 77?
Here is a code
#include<stdio.h>
int main()
{
int i=5;
printf("%d%d",++i,++i);
}
I am not understand, why the output is 77?
++i
and i++
are expressions that have side effects. Using two of these in the same expression results in undefined behavior. Basically, anything goes.
Specifically, I'm guessing the compiler says you want to increment i
twice and then use the result, so it evaluates ++i
twice, resulting in 7
, and then sends that to printf
.