Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Expression and evaluation order (http://www.go4expert.com/forums/expression-evaluation-t4528/)

nehamayor 2Jun2007 22:40

Expression and evaluation order
 
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

shabbir 3Jun2007 08:44

Re: Expression and evaluation order
 
Yes your understanding is absolutely correct and the evaluation is done based on preference.

By the way Neha, welcome to the forum


All times are GMT +5.5. The time now is 04:12.