Seriously though anything except '0' is true, do you have a more specific roadblock? I know that some functions return 0 when there are no errors like your int main() function does and that still trips me up from time to time.
He was asking for boolean operators, not for boolean values. C++ has the following boolean operators:
A && B : the statement is true, when A and B are both true, otherwise it is false
A || B : the statement is true when A or B (or both) are true, otherwise it is false
!A : The statement is true when A is false.
The operators may be combined to create more complicated expressions, for example:
!A && !B : This is true when A and B are both false (equal to !(A || B)
!(A&&B) : This is true when either A or B are false (equal to !A || !B)
(A || B) && (C || D) : this is true when A, B or both are true, and at the same time C,D or both are true
(!A && B) || (A && !B) : this is true when either A or B are true, but false when both are true or both are false
Then there are the following comparison operators:
A == B : true when A is equal to B (note, that doesn't necessarily imply that A IS B)
A != B : true when A is not equal to B
A < B : true when A is smaller than B
A > B : true when A is greater than B
A <= B : true when A is smaller or equal to B
A >= B: true when A is greater or equal to B
Note that types in C++ are allowed to overload those operators, so the actual meaning depends on the type the operators are applied to (some types may not have such operators at all, depending on whether they actually make sense). However, you can normally expect these to behave in a way that makes sense for the type they are implemented.
these are the examples in the tutorial im reading and I cant really understand how they came about the answer
A. !( 1 || 0 ) ANSWER: 0
B. !( 1 || 1 && 0 ) ANSWER: 0 (AND is evaluated before OR)
C. !( ( 1 || 0 ) && 0 ) ANSWER: 1 (Parenthesis are useful)
and this is on the quiz
Evaluate !(1 && !(0 || 1))
this is like my second day learning c++, I dont want it to discourage me from learning it because im really interested in learning it and i want to study it in college. I want to learn a bit so that im sure il do well in college
A. you evaluate what's in the parenthesis first: 1 || 0 will evaluate to 1 (and so is 0 || 1, and 1 || 1), then you negate it thus giving !(1) which is 0; you also can read || as OR and ! as NOT
I'll leave it to you to figure out B and C:
clues: && = AND, and only 1 AND 1 evaluates to 1, others evaluate to 0;