1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Expression and evaluation order

Discussion in 'C' started by nehamayor, Jun 2, 2007.

  1. nehamayor

    nehamayor New Member

    Joined:
    Jun 2, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hi

    I am bit confused with evaluation order in expressions.Say for example in the following expression

    i + j + k++

    is subexpression k++ before any of the other operators.My understanding goes like this

    1) As ++ has higher precedence then +,(k++) is evaluated first
    2) then arithmetic + operators is evaluated from left to right

    So is my understanding correct?

    So can it be said tht given an expression all the unary operators are evaluated before any of the binary operators.


    thanks,
    neha
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,287
    Likes Received:
    364
    Trophy Points:
    83
    Yes your understanding is absolutely correct and the evaluation is done based on preference.

    By the way Neha, welcome to the forum
     

Share This Page