What will be the output for it ?

Hello everyone ..

I just looked at a question .It was written something like that .


int i=10;
i=i++;
printf("%d",i);


I wonder what will be the value of "i".PLease anyone can give me a detailed information about it.? I will be very thankfull to him.
closed account (z05DSL3A)
What do you think it is and why do you think that?

The answer is that it is compiler dependent. It could be 10, it could be 11...

for example the compiler may do something along the line of
i = i++
i = (temp = i) and increment i : temp is now 10 and i is now 11
i = temp : now i = 10 again

or
i = i++
i = i and increment i : i is now 10 and then i is 11
Last edited on
Topic archived. No new replies allowed.