help with c/c++

Status
Not open for further replies.

dare_devil

Broken In
[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

हॉर्न ओके प्लीज़
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!
 
OP
dare_devil

dare_devil

Broken In
thanks, but i know priorities, but i am unable to understand behavior of these in an expression and functions
 

srinivasa.s

Right off the assembly line
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
 
Status
Not open for further replies.
Top Bottom