# Thread: WHAT DO YOU MEAN, in tutors?

1. ## WHAT DO YOU MEAN, in tutors?

Hi,
i thinked i will laern from the tutors from this site, so i read 2 first lessons until now!
But in second, I didn't get some things.
At the end you have this:
NOT: The NOT operator accepts one input. If that input is TRUE, it returns FALSE, and if that input is FALSE, it returns TRUE. For example, NOT (1) evalutes to 0, and NOT (0) evalutes to 1. NOT (any number but zero) evaluates to 0. In C and C++ NOT is written as !. NOT is evaluated prior to both AND and OR.

AND: This is another important command. AND returns TRUE if both inputs are TRUE (if 'this' AND 'that' are true). (1) AND (0) would evaluate to zero because one of the inputs is false (both must be TRUE for it to evaluate to TRUE). (1) AND (1) evaluates to 1. (any number but 0) AND (0) evaluates to 0. The AND operator is written && in C++. Do not be confused by thinking it checks equality between numbers: it does not. Keep in mind that the AND operator is evaluated before the OR operator.

OR: Very useful is the OR statement! If either (or both) of the two values it checks are TRUE then it returns TRUE. For example, (1) OR (0) evaluates to 1. (0) OR (0) evaluates to 0. The OR is written as || in C++. Those are the pipe characters. On your keyboard, they may look like a stretched colon. On my computer the pipe shares its key with \. Keep in mind that OR will be evaluated after AND.

It is possible to combine several boolean operators in a single statement; often you will find doing so to be of great value when creating complex expressions for if statements. What is !(1 && 0)? Of course, it would be TRUE. It is true is because 1 && 0 evaluates to 0 and !0 evaluates to TRUE (ie, 1).

Try some of these - they're not too hard. If you have questions about them, feel free to stop by our forums.
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)

If you find you enjoyed this section, then you might want to look more at Boolean Algebra.
Can i see example of these things in open source code becausei didn't get how we are writing them,
thanks

2. Code:
```int num1, num2;
cout << "Enter two numbers: ";
cin >> num1 >> num2;
// Do something if all are positive
if( num1 >= 0 && num2 >= 0 )
{
// Do stuff
}
// Do something if only one of numbers is positive
if( (num1 >= 0 && num2 < 0) || (num1 < 0 && num2 >= 0) )
{
// Do stuff
}```

3. ## Try to think about the logic....

The fact that these operators "evaluate" to one or zero might add to the confusion. Try to think TRUE or FALSE, rather than one & zero.

But, you should know that zero is FALSE, and any other number is TRUE. This means that I can write if (n - 5)... And, I can write if(n)...

some simple logic exampes:
If the user presses [ENTER], then do something. If the user's name is NOT "Doug", then exit.

Or, "If color is blue OR green, then..." "If animal is a dog, AND it's hair is NOT blue, then..."

Most online tutorials are very condensed. I recommend that you get a book, and use more than one online source. Here's another tutorial.

4. ok i think i get some things
I WISH I KNew c++ LIKE YOU GUYS