## Satisfied

- 1 comparison operators
- 2 logical operators
- 2.2 o (||)
- 2.3 no(!)

### comparison operators[To edit|edit source]

the operators**<**(less than),**>**(but bigger than),**<=**(equal to less than),**>=**(Better than or equal to),**==**(and even**!=**(not equal) are relational operators used to compare two values. Variables can be compared to another variable or to a literal.

He**<**The operator checks if the first operand is less than the second operand. If the first operand is less than the second, true is returned. Otherwise, it returns false.

**examples**

E T x =5;E T j = 1;E (x < 10) //x is 5 which is less than 10 returns true{ //...Código...}E (x < 0) //x is 5 which is not less than 0 returns false{ //...Código...}E (x < j) //x is 5 and y is 1. 5 is not less than 1, returns false{ //...Código...}

He**>**The operator checks if the first operand is greater than the second operand. If the first operand is greater than the second operand, true is returned. Otherwise, it returns false.

**examples**

E T x =12;E T j = 1;E (x > 10) //x is 12 which is greater than 10 returns true{ //...Código...}E (x > 15) //x is 12 which is not greater than 15 will return false{ //...Código...}E (x > j) //x is 12 and y is 1. 12 is greater than 1, returns true{ //...Código...}

He**<=**The operator checks if the first operand is less than**o**equal to the second operand. If the first operand is less than or equal to the second operand, true is returned. Otherwise, it returns false.

**examples**

E T x = 12;E T j = 12;E (x <= 12) //x is 12 which is less than or equal to 12 returns true{ //...Código...}E (x <= 5) //x is 12 which is not less than or equal to 5 returns false{ //...Código...}E(x <= j) //x is 12 and y is 12. 12 is less than or equal to 12, returns true{ //...Código...}

He**>=**The operator checks if the first operand is greater than**o**equal to the second operand. If the first operand is greater than or equal to the second operand, true is returned. Otherwise, it returns false.

**examples**

E T x = 12;E T j = 12;E (x >= 12) //x is 12 which is greater than or equal to 12 returns true{ //...Código...}E (x >= 19) //x is 12 which is not greater than or equal to 19 will return false{ //...Código...}E (x >= j) //x is 12 and y is 12. 12 is greater than or equal to 12, returns true{ //...Código...}

He**==**The operator checks whether the first operand is equal to the second operand. If the first operand is equal to the second operand, true is returned. Otherwise, it returns false.

**examples**

E T x = 5;E T j = 6;E (x == 5) //x is 5, which equals 5, returns true{ //...Código...}E (x == 7) //x is 5, which is not equal to 7, returns false{ //...Código...}E (x == j) //x is 5 and y is 6. 5 is not equal to 6, returns false{ //...Código...}

He**!=**The operator checks that the first operand is not equal to the second operand. If the first operand is not equal to the second operand, true is returned. Otherwise, it returns false.

**examples**

E T x = 5;E T j = 6;E (x != 5) //x is 5, which equals 5, returns false{ //...Código...}E (x != 7) //x is 5, which is not equal to 7, returns true{ //...Código...}E (x != j) //x is 5 and y is 6. 5 is not equal to 6, returns true{ //...Código...}

### logical operators[To edit|edit source]

the operators` Y`(can also be written as

**&&**) Y

`(can also be written as`

**o****||**) allow the concatenation of two or more conditions. He

`The operator checks that all conditions are true and the`

**Y**`The operator checks if at least one of the conditions is true. Both operators can also be mixed, where the order they appear from left to right determines how checks are performed. Earlier versions of the C++ standard used the keywords`

**o****&&**Y

**||**rather than

`Y`

**Y**`. Both operators are considered`

**o***short circuit*. and a previous

`Condition is false, subsequent conditions are not checked. If a previous`

**Y**`Condition is true Postconditions are not checked.`

**o****To use:**

The iso646.h header file has been part of the C standard library since 1995 as a supplement to the C90 standard. Defines a set of macros that allow programmers to use bitwise C language logical operators in text form that cannot be quickly or easily typed on some international, non-QWERTY keyboards without the header file. These symbols are keywords in the ISO C++ programming language and do not require a header file. However, for consistency, the C++98 standard provides the <ciso646> header. In MS Visual Studio, which has implemented non-standard language extensions in the past, this is the only way to enable these keywords (via macros) without disabling the extensions.

He` no`(can also be written as

**!**The ) operator is used to return the inverse of one or more conditions.

**Syntax**:

condition1Ycondition2condition1ocondition2noIllness

**examples**:

If something must not be right. It is often combined with other conditions. If x>5 but not x=10, you would write:

E ((x > 5) Y no (x == 10)) // if (x greater than 5) and (not (x equals 10)){ //...Código...}

When all conditions must be true. If x must be between 10 and 20:

E (x > 10 Y x < 20) // if x is greater than 10 and x is less than 20{ //....Código...}

When at least one of the conditions must be true. If x must be equal to 5 or equal to 10 or less than 2:

E (x == 5 o x == 10 o x < 2) // if x equals 5 or x equals 10 or x is less than 2{ //...Código...}

Whether at least one condition in a group of conditions must be true. Whether x must be between 10 and 20 or between 30 and 40.

E ((x >= 10 Y x <= 20) o (x >= 30 Y x <= 40)) // >= -> greater than or equal to etc...{ //...Código...}

With more conditions it gets a little more complicated. The trick is to make sure the square brackets are in the right places to establish the intended thought order. However, when things get this complex it can often be easier to break the logic into nested if statements or put them in boolean variables, but it's still useful to be able to do things in complex boolean logic.

stick around`X > 10`and around`X < 20`they are implied like that`<`Operator has higher priority than` Y`. First

`x`compared to 10. If

`x`is greater than 10,

`x`is compared to 20, and if

`x`is also less than 20, the code will be executed.

#### S (&&)[To edit|edit source]

statement1 | statement2 | Y |
---|---|---|

T | T | T |

T | F | F |

F | T | F |

F | F | F |

The AND logical operator,**Y**, compares the value on the left and the value on the right. yes both*statement1*Y*statement2*are true, the expression returns TRUE. Otherwise, FALSE is returned.

E ((var1 > var2) Y (var2 > var3)){ Standard::cout << var1 " is bigger than " << var2 << "Y" << var3 << Standard::fin;}

In this section, the**E**statement checks if*var1*is bigger than*var2*. Then it checks whether*var2*is bigger than*var3*. If so, keep telling us*var1*is bigger than both*var2*Y*var3*.

**To use:**

The logical AND operator**Y**is sometimes written as**&&**, which is not the same as the direction operator and the bitwise AND operator, which are represented by**&**

#### o (||)[To edit|edit source]

statement1 | statement2 | o |
---|---|---|

T | T | T |

T | F | T |

F | T | T |

F | F | F |

The OR logical operator is represented by**o**. Like the logical AND operator, it compares*statement1*Y*statement2*. if there are*statement1*o*statement2*are true, then the expression is true. The expression is true even if both statements are true.

E ((var1 > var2) o (var1 > var3)){ Standard::cout << var1 " is bigger than " << var2 << "o" << var3 << Standard::fin;}

Let's look at the expression above with an OR operator. Yes*var1*is bigger than both*var2*o*var3*or both, the statements in the**E**expression to be executed. Otherwise, the program continues with the rest of the code.

#### no (!)[To edit|edit source]

The logical operator NOT,**no**, returns TRUE if the statement being compared is not true. Be careful when using the NOT operator and any logical operators.

no x > 10

Logical expressions have higher precedence than normal operators. Therefore, a comparison is made to see if "not x" is greater than 10. However, this statement always returns false, no matter what "x" is. This is because logical expressions only return Boolean values (1 and 0).