math problems for c++

Assume that:
x = 10; y = 20; z = 30;

if ( x==10 && y<x || z>y )
cout<<"TRUE";
else cout<<"FALSE";


if ( y>z && (z<x || z>y) )
cout<<"TRUE";
else cout<<"FALSE";


if ( x != 10 || x = z )
cout<<"TRUE";
else cout<<"FALSE";

Any answers will help.

Thanks
Slypenguinz



that's logic, not maths. what do you want to do with that? there's a mistake in the last if. x = z is assignment and should be x == z.
hamsterman sorry should have said logic, but these are practice test questions not sure if they would return true or false, and the last one probably is a trick question, my teacher said there would be one.
Also you need to eliminate ambiguity by adding (). Not sure how the compiler would interpret: if ( x==10 && y<x || z>y ), but humans can interpret it as: If x == 10, and EITHER y < x OR z > y or as: If BOTH x == 10 AND y < x, OR z > y. The first interpretation is true, whereas the second is false.
Last edited on
You don't seem to be actually asking a question?
wtf, the priority of operators is defined. && happens before ||.
slypenguinz, why not compile it?
hamsterman i didnt think of trying it... Thanx you solved my problem
I appreciate everybodies time and attention
Is this some sort of joke?
no wtf this was a problem my C professor gave me, and i have been in the class for about 2 weeks
Topic archived. No new replies allowed.