1. ## order of precedence

Hi people!

I've been going through "the C puzzle book" by Alan R. Feuer
and i've come across something that doesn't seem right to me
but the book gives very little explantion so could somebody help me out?

The exercise is to find the value of x from this;

x=(7+6) % 5 / 2;

what i dont get is that the book says to solve it like this;

x=((7+6) % 5)/2 so x=1

but / is above % in the order of precedence so shouldn't it be

x=(7+6)%(5/2)

giving a completely different answear?

Have i just not thought this through right? Is my braining playing tricks on me?

2. >but / is above % in the order of precedence
/ and % have the same precedence, and left to right associativity.

3. ## woops

but / is above % in the order of precedence
sorry, i mean that the division will be done....errr....before the modulos so why is the answear like this?;

x=((7+6) % 5)/2 so x=1

4. As Prelude said, both / and % have the same precedence, which means that they will be executed in order of appearance from left to right.

5. well look at the following code. Guess why the output is 34. And definitely u will understand why x = 1

Code:
```#include<stdio.h>

int main()
{
int i=10;

printf("%d",(i++ + ++i)+ ++i);

getchar();
return 0;
}```
ssharish2005

6. Except that your example is undefined, due to it modifying i multiple times in the same line of code.

7. thanks guys!

I think i gte it now....

later