Please read it before making it duplicate.
From the book which I have read:
Associativity can be of two types:
1-Left to Right
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.
2-Right to left
same as above.
Now please read the following code:
/* no of item purchased>1000 then discount of 10% else full price */
printf("Enter the no of item purchased");
printf("Enter the price per item");
if(n > 1000)
p = n * r;
printf("Price before discount = %f\n", p);
d = 10 / 100 * p; //please have a carefull look at d
printf("discount offered is = %f\n", d);
t = p - d;
printf("total price after discount = %f\n", t);
p = n * r;
printf("total price is = %f", p);
/ are left-to-right operators. They even have the same precedence.
Therefore, your expressions can be re-written like so without changing their meaning:
d = (10 / 100) * p d = (p * 10) / 100
10 / 100 is an integer division with the result
0, hopefully now you can see the difference.