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

What are the logical operators in c++

下次还敢
Release: 2024-05-01 12:15:23
Original
1151 people have browsed it

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!

Related labels:
c++
source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template