c++ doubt

Discussion in 'C++' started by jainprateek2000, Dec 9, 2009.

  1. jainprateek2000

    jainprateek2000 New Member

    Joined:
    Aug 24, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    a=5,c are integers
    d=1.5 is floating type
    evaluate
    c=(a++)*d+a
     
  2. venami

    venami New Member

    Joined:
    Dec 26, 2008
    Messages:
    195
    Likes Received:
    10
    Trophy Points:
    0
    Occupation:
    Software Professional
    Location:
    India, Tamil Nadu, Cuddalore
    Home Page:
    http://mvenkatapathy.wordpress.com
    c=(5*1.5)+6
     
  3. Gene Poole

    Gene Poole New Member

    Joined:
    Nov 10, 2009
    Messages:
    93
    Likes Received:
    5
    Trophy Points:
    0
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice