Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   c++ doubt (http://www.go4expert.com/forums/cpp-doubt-t20321/)

jainprateek2000 9Dec2009 21:17

c++ doubt
 
a=5,c are integers
d=1.5 is floating type
evaluate
c=(a++)*d+a

venami 9Dec2009 22:53

Re: c++ doubt
 
c=(5*1.5)+6

Gene Poole 9Dec2009 23:08

Re: c++ doubt
 
I believe it should be 12. The a++ is superfluous to this expression as it won't be evaluated until after the full expression (after the semicolon) so it has no affect on the outcome; however, I seem to recall from the C++ standard that the behavior of an expression involving a postfix or prefix operator and the operand of those operators in the same expression is undefined.


All times are GMT +5.5. The time now is 01:39.