Re: [algogeeks] A SIMPLE C++ PROGRAM.
What about the people explaining the answer above as '12'saying processing will start from left in cout and write in printf ?? On Sun, May 1, 2011 at 1:33 AM, Amit Jaspal amitjaspal...@gmail.com wrote: This is compiler dependent..and not a portable way of writing code On Sat, Apr 30, 2011 at 12:11 PM, Ashish Modi ashishrmod...@gmail.comwrote: For such type of questions, the best method is to draw a parse tree according to precedence and evaluate the tree. This is how it is evaluated at compiler level. Many times parsing tree creation is implementation dependent. On Fri, Apr 29, 2011 at 6:43 PM, Varun Nagpal varun.nagp...@gmail.comwrote: I think these questions are stupid in the sense that no one would ever use these constructs in their production code unless someone wants to write an obscure obfuscated code in some competition. Many times similar expressions are non-portable. Anyways, to understand this and related concepts, please see iso c or c++ standard and try to understand operator precedence, operator associativity and sequence points. On Fri, Apr 29, 2011 at 3:06 PM, Nikhil Gupta nikhilgupta2...@gmail.com wrote: 12 5 because y=4+4+3+1 and x is incremented to 5 On Fri, Apr 29, 2011 at 2:01 PM, MANNU manishkr2...@gmail.com wrote: *Can anyone please explain me the output of this program:* int x=1; int y=x++ + ++x + ++x + x++; couty; coutx; -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Nikhil Gupta Senior Co-ordinator, Publicity CSI, NSIT Students' Branch NSIT, New Delhi, India -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards Ashish Modi 9423721478 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Amit Jaspal. Men do less than they ought, unless they do all they can -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] A SIMPLE C++ PROGRAM.
x=5 y=10 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] A SIMPLE C++ PROGRAM.
The above code is purely compiler dependent.Google Sequence Points. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] A SIMPLE C++ PROGRAM.
This is compiler dependent..and not a portable way of writing code On Sat, Apr 30, 2011 at 12:11 PM, Ashish Modi ashishrmod...@gmail.comwrote: For such type of questions, the best method is to draw a parse tree according to precedence and evaluate the tree. This is how it is evaluated at compiler level. Many times parsing tree creation is implementation dependent. On Fri, Apr 29, 2011 at 6:43 PM, Varun Nagpal varun.nagp...@gmail.comwrote: I think these questions are stupid in the sense that no one would ever use these constructs in their production code unless someone wants to write an obscure obfuscated code in some competition. Many times similar expressions are non-portable. Anyways, to understand this and related concepts, please see iso c or c++ standard and try to understand operator precedence, operator associativity and sequence points. On Fri, Apr 29, 2011 at 3:06 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: 12 5 because y=4+4+3+1 and x is incremented to 5 On Fri, Apr 29, 2011 at 2:01 PM, MANNU manishkr2...@gmail.com wrote: *Can anyone please explain me the output of this program:* int x=1; int y=x++ + ++x + ++x + x++; couty; coutx; -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Nikhil Gupta Senior Co-ordinator, Publicity CSI, NSIT Students' Branch NSIT, New Delhi, India -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards Ashish Modi 9423721478 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Amit Jaspal. Men do less than they ought, unless they do all they can -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] A SIMPLE C++ PROGRAM.
For such type of questions, the best method is to draw a parse tree according to precedence and evaluate the tree. This is how it is evaluated at compiler level. Many times parsing tree creation is implementation dependent. On Fri, Apr 29, 2011 at 6:43 PM, Varun Nagpal varun.nagp...@gmail.comwrote: I think these questions are stupid in the sense that no one would ever use these constructs in their production code unless someone wants to write an obscure obfuscated code in some competition. Many times similar expressions are non-portable. Anyways, to understand this and related concepts, please see iso c or c++ standard and try to understand operator precedence, operator associativity and sequence points. On Fri, Apr 29, 2011 at 3:06 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: 12 5 because y=4+4+3+1 and x is incremented to 5 On Fri, Apr 29, 2011 at 2:01 PM, MANNU manishkr2...@gmail.com wrote: *Can anyone please explain me the output of this program:* int x=1; int y=x++ + ++x + ++x + x++; couty; coutx; -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Nikhil Gupta Senior Co-ordinator, Publicity CSI, NSIT Students' Branch NSIT, New Delhi, India -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards Ashish Modi 9423721478 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] A SIMPLE C++ PROGRAM.
Thanks for help. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] A SIMPLE C++ PROGRAM.
*Can anyone please explain me the output of this program:* int x=1; int y=x++ + ++x + ++x + x++; couty; coutx; -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] A SIMPLE C++ PROGRAM.
*I can't explain it.* * * This code is evil, never coding like this. It's relate to specific C++ compiler implement. That's all my know about it. This my first post at googlegroups. Hello everyone. :) On Fri, Apr 29, 2011 at 4:31 PM, MANNU manishkr2...@gmail.com wrote: *Can anyone please explain me the output of this program:* int x=1; int y=x++ + ++x + ++x + x++; couty; coutx; -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] A SIMPLE C++ PROGRAM.
here y= 1+ 3+4+4= 12 and x=5 here just follow rules of postfix and prefix operator thanks manish -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] A SIMPLE C++ PROGRAM.
Manish is right. This would start from the left. In cout also processing starts from left. The processing is from right in the printf statement. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tusharbin...@jugadengg.com Website: www.jugadengg.com -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] A SIMPLE C++ PROGRAM.
Manish is right. I'm so sorry, the evil code what I said before is uglier as follows int x=1; int y=x++ + ++x + ++x - x++; couty; Forgive my careless please...:( On Fri, Apr 29, 2011 at 4:31 PM, MANNU manishkr2...@gmail.com wrote: *Can anyone please explain me the output of this program:* int x=1; int y=x++ + ++x + ++x + x++; couty; coutx; -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] A SIMPLE C++ PROGRAM.
Yes it is correct that if we apply rules for postfix and prefix operators, the answer should be 12,5 but it is showing 10,5. So please explain this. Thanks and Regards DEVANSH GUPTA B.TECH SECOND YEAR COMPUTER SCIENCE AND ENGINEERING MNNIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] A SIMPLE C++ PROGRAM.
I think these questions are stupid in the sense that no one would ever use these constructs in their production code unless someone wants to write an obscure obfuscated code in some competition. Many times similar expressions are non-portable. Anyways, to understand this and related concepts, please see iso c or c++ standard and try to understand operator precedence, operator associativity and sequence points. On Fri, Apr 29, 2011 at 3:06 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: 12 5 because y=4+4+3+1 and x is incremented to 5 On Fri, Apr 29, 2011 at 2:01 PM, MANNU manishkr2...@gmail.com wrote: *Can anyone please explain me the output of this program:* int x=1; int y=x++ + ++x + ++x + x++; couty; coutx; -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Nikhil Gupta Senior Co-ordinator, Publicity CSI, NSIT Students' Branch NSIT, New Delhi, India -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.