Home  >  Article  >  Backend Development  >  What are the logical operators in c++

What are the logical operators in c++

下次还敢
下次还敢Original
2024-05-01 12:15:231107browse

Logical operators in C

Logical operators are used to operate on Boolean values ​​(true/false) and generate new Boolean values. There are three logical operators in C:

  • ##AND (&&)
  • ##OR (||)
  • NOT(!)
  • ##AND (&&)

AND operator returns true if and only if its two operands All are true. Otherwise, it returns false. The table is as follows:

Operation 1Operation 2Result##truetruefalsetruefalseOR (||)
true true
false #false
false false
false

OR operator returns true if and only if one of its two operands is true. Otherwise, it returns false. The table is as follows:

Operation 1Operation 2##truetruetruetruefalsetrue#falsetruetruefalsefalse falseNOT (!)
Result
NOT operator is a unary operator that inverts the boolean value of its operand . true becomes false and false becomes true. The table is as follows:

Operation

Resulttruefalsefalsetrue

The above is the detailed content of What are the logical operators in c++. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn