Hi!
Would have been nice to let us know, which language you are referring to. I will simply assume C. A second hint i would like to give is to use code tags. This little bastards help reading your code.
I am not sure, but i guess you mixed up the comparison operator "==" and the assignment operator "=". Your second example will change the value of c to '\0', '\n' or '\t', depending in which order you write your "logical expression". Each of the three expressions first changes the value of c, and after that, it will take the new value and will interpret that as a logical value, which will almost always be true.
If you did use the "=" for a reason, i don't have a clue about what your question is exactly...
Edit:
There is another little flaw in your post about operator precedence, if we are talking about C:
Logical AND "&&" has a precedence of 5 while logical OR "||" has only 4. That for your upper expression should be evaluated as:
X OR ( Y AND Z )
This example demonstrates the behavior:
Code:
#include <stdio.h>
int main(int c, char * argv[])
{
int x = 1;
int y = 1;
int z = 0;
if (x||y&&z)
printf("true\n");
else
printf("false\n");
}
If your assumption was right, x and y would evaluate to true, but true and false would result in a false...
Anyway, tests on my machine result in true...
Regards, Heraton