DIGIT-ARC read-only archive · snapshot: July 23, 2026

help with c/c++

4 posts · originally from https://geek.digit.in/community/threads/help-with-c-c.101480/

dare_devil
dare_devil Original post #1
Nov 6, 2008 at 7:24 PM
[NOPARSE]
please help me finding correct explanation for following problems


1:) int i=5;
printf("%d", i++ *++i);

2:)int i=5,j=6;
printf("%d",i+++j);

3:) what's difference between these two outputs, i mean why out put different
j=5;
i=j++ * ++j;
and
j=j++ *++j;


please help me
[/NOPARSE]
victor_rambo
Nov 6, 2008 at 7:37 PM
I am a PHP guy, but let me see if the same explanation is valid for C too!

a++ means a is returned before incrementing
++a means a is first incremented and then returned!

again, I am a PHP guy, so this may be wrong!
dare_devil
Nov 6, 2008 at 7:41 PM
thanks, but i know priorities, but i am unable to understand behavior of these in an expression and functions
S
Nov 6, 2008 at 10:14 PM
Except for the second one, both 1 and 3 that you've given have undefined behavior. What this means that you cannot predict what the output would be and may vary on different compilers.

This is because the same variable is being modified twice between 2 sequence points. For more details, search the net for "C sequence points"

Hope this helps
Srinivasa S