What is the Output of this program

0 views
Skip to first unread message

venkatesh devarajan

unread,
Nov 18, 2011, 5:36:12 AM11/18/11
to pas...@googlegroups.com
 C Guru's out there

Explain why the below code is printing is 2022

# include<stdio.h>

void main(){

int j=1;

printf("%d %d %d %d", ++j, j++, j, --j

}
         

Sriram Seshadri

unread,
Nov 18, 2011, 6:01:09 AM11/18/11
to pas...@googlegroups.com
i m no guru, just a crawler but hey I found this for you.


Typically its undefined behavior which_is_documented as ppl say here..





Any other answers anybody ?


-Sriram


         

--
You received this message because you are subscribed to the Google Groups "Vetti Pasange..." group.
To post to this group, send an email to pas...@googlegroups.com.
To unsubscribe from this group, send email to pasange+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pasange?hl=en-GB.



--
                                                             sriram

Ramanathan

unread,
Nov 18, 2011, 6:03:36 AM11/18/11
to pas...@googlegroups.com
I think the code will not compile.

Close parenthesis and semi-colon missing :P
Regards,
Ramanathan S

Sriram Seshadri

unread,
Nov 18, 2011, 6:14:21 AM11/18/11
to pas...@googlegroups.com
You can rape the above code here to find out y is undefined..!


Seri venkatesh athulaam irukattum endha company? :)

venkatesh devarajan

unread,
Nov 18, 2011, 6:16:18 AM11/18/11
to pas...@googlegroups.com
SuccessFactors Machi :)

Sriram Seshadri

unread,
Nov 18, 2011, 6:37:56 AM11/18/11
to pas...@googlegroups.com
Sorry that was a wrong codepad link which is read only..you can play around here...

srinath subramanian

unread,
Nov 18, 2011, 6:43:10 AM11/18/11
to pas...@googlegroups.com
venkatesh, helping some cute looking developer huh?

Sriram Seshadri

unread,
Nov 18, 2011, 7:04:22 AM11/18/11
to pas...@googlegroups.com

@Subbu aama da looks like venky is up for a mindfuck for a free fuck. :) :)

Reply all
Reply to author
Forward
0 new messages