Question on prefix and post fix
-
Dear All, I have a query on following case.Can some body tell the solution for the following: y = 5++++6*3; The answer turns out to be -12 when checked with a C compiler Also, i tried the same on borland delphi 5 and got the answer as 24 How is the processing going on in the above case. Thanks, Regards, Rohit
-
Dear All, I have a query on following case.Can some body tell the solution for the following: y = 5++++6*3; The answer turns out to be -12 when checked with a C compiler Also, i tried the same on borland delphi 5 and got the answer as 24 How is the processing going on in the above case. Thanks, Regards, Rohit
Rohit Divas wrote: y = 5++++6*3; :wtf: I would think code that would not even compile. No wonder it is giving you indeterminate results.
[
](http://www.canucks.com)"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!
-
Dear All, I have a query on following case.Can some body tell the solution for the following: y = 5++++6*3; The answer turns out to be -12 when checked with a C compiler Also, i tried the same on borland delphi 5 and got the answer as 24 How is the processing going on in the above case. Thanks, Regards, Rohit
I tried to compile that in some code, and didn't succeed at all. it didn't like the ++ after the 5. I believe it expects a variable. so i'm not sure how you got that to compile :( why are you doing ++++ anyway?
-
I tried to compile that in some code, and didn't succeed at all. it didn't like the ++ after the 5. I believe it expects a variable. so i'm not sure how you got that to compile :( why are you doing ++++ anyway?
yes i did the same and it complied successfully on borland delphi 5 compiler, rohit
-
yes i did the same and it complied successfully on borland delphi 5 compiler, rohit
but you said you got -12 when compiled with the C-compiler. It doesn't even look like valid C-code. If there's one thing I've learned, it's that life is one crushing defeat after another until you just wish Flanders was dead. - Homer Simpson
-
Rohit Divas wrote: y = 5++++6*3; :wtf: I would think code that would not even compile. No wonder it is giving you indeterminate results.
[
](http://www.canucks.com)"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!
PJ Arends wrote: I would think code that would not even compile. I agree - it shouldn't - there's a missing operation between the 5++ and the ++6. I suspect someone's posted incorrect code, with a missing or extraneous '+' along the way. Either way, the C++ standard makes no specific guarantees about the order that statement is executed in - a set of operations can be performed in any order if they are within the same sequence point and the rules of precedence don't kick in, IIRC. So we're probably looking at undefined behaviour, hence the different results (watch out for those nasal demons :-))