Go4Expert (http://www.go4expert.com/)
-   Engineering Concepts (http://www.go4expert.com/forums/engineering-concepts/)
-   -   associativity of operators in C language (http://www.go4expert.com/forums/associativity-operators-c-language-t5648/)

 hitesh_best 3Aug2007 19:45

associativity of operators in C language

Hello friends,

I am following Let us C, 6th edition, by Yashavant Kanetkar,
I have a problem understanding the concept of associativity of operators,

I tried to find some good material on internet by searching in google but could not find much.

Kanetkar writes,

"Left to Right associativity means that the left operand must be unambiguous. Unambiguous in what sense? It must not be involved in evaluation of any other sub-expression. Similarly in case of Right to Left associativity the right operator must be unambiguous."

I could not understand what it means by "being unambiguous".

There is a expression,

Code:

` g = 10/5/2/1`
Now we have to find the order in whcih the calculations will take place
In his solution book, he gives the solution.

Code:

```    operator            left                          Right                        Remark             /              10                        5 or 5/2/1              Left operand is unambiguous,                                                                                             Right is not         /              10/5 or 5                  2 or 2/1            Left operand is unambiguous,                                                                                             Right is not         /              10/5/2 or 2                1                      Right operand is unambiguous,                                                                                             Left is not```
Now in first row and right column why he writes only two operands that are possible: 5 or 5/2/1 why also not 5/2

In the second row in the remark column why he says that left operand is unambiguous when there are two operands that are possible i.e. 10/5 or 5.

Thanks a lot

 hitesh_best 3Aug2007 21:02

Re: associativity of operators in C language

Friends, admitting my mistake I have started the same thread in C/C++ forum . I think this thread should be there. Please forgive me for this.

 shabbir 4Aug2007 12:16

Re: associativity of operators in C language

Quote:
 Originally Posted by hitesh_best Friends, admitting my mistake I have started the same thread in C/C++ forum . I think this thread should be there. Please forgive me for this.
Duplicate of associativity of operators in C language . Thread closed.

 All times are GMT +5.5. The time now is 00:22.