int main()
{
  int a,b,c;
  a=b=c=1;
  c = ++a || ++b && ++c;
  printf("%d %d %d", a,b,c);
}

here the expression is considered from left to right.
but the confusion of mine is:

&& has got higher precedence than that of ||.
so ++b && ++c should be calculated first.
why it so happens that when ++a which is true is found the rest of the expression is not even considered.
i find the output as:
2 1 1
plz. help..

Because true OR true is always going to be true, and true OR false is always going to be true. Operator precedence does not necessarily mean operation precedence (that's not the right word, i just don't know how to explain it). That is, the AND will be evaluated before the OR, but the OR is still seen before the AND.

a=b=c=1

a will be set equal to the value that is in b.
Then b will be set equal to the value in c.
Last c will be set to 1.

This is the challenge of this type of statement.

Logic expressions are true when not equal to zero.
Even a negative number is considered true.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.