C Language: Logical operators

Source: Internet
Author: User

Logic and operators && logic or operators | | The result of the logical non-operator!  operation is only 2, "true" is 1, "false" is 0 && logic and operator  1. Use format   condition a && conditional b 2. The result of the operation is only when condition A and condition B are true, the result is 1, which is true, and the rest of the case is 0, which is false, so if a condition a or condition B is not true, the result is 0, that is, the combination of false   logic is: From left to right   If the value of a is 4: First Judge A>3, set up, and then Judge A<5, also established. So the result is 1  if the value of a is 2: First Judge A>3, not set up, stop judging. So the result is 0  therefore, if the value of a is within the range of (3, 5), the result is 1; otherwise, the result is 0  | | Logical OR operator  1. Use format   condition A | | Condition b 2. Results   When condition A or condition B is set up (also including condition A and condition B), the result is 1, which is "true", and only if condition A and condition B are not set, the result is 0, which is "false".   Logic and the combination of the way is: from left to right   always first determine whether condition A is set up   if condition A is established, it will not be judged whether the condition B is set up, because condition A has been established, regardless of condition B, it is determined to be true, that is, 1.  If the condition A is not established, then to determine whether the condition B is set up, if the condition B is set up, the result is also true, that is, 1, if the condition B is not established, that is false, that is 0.  example:  if a value is 4: First Judge a<3, not set; 5, nor is it tenable. So the result is 0  if the value of a is 2: First Judge A<3, set up, stop judging. So the result is 1 . Therefore, if the value of a is within the range of (-∞, 3) or (5, +∞), the result is 1; otherwise, the result is 0 ! logical non-use format  ! Condition a  operation result   actually is to take the inverse of condition A: If condition A is established, the result is 0, namely "false", if condition A is not established, the result is 1, namely "true". That is to say: true false, False true   logical non-union direction is "from right to left". Like an expression! (a>5)   If the value of a is 6: First Judge A>5, set up, and then take the result of 0  if the value of a is 2: first Judge a>3, not set, and then take the result of the inverse is 1  therefore, if the value of a is greater than 5, the result is 0; otherwise, the result is 1.

C language: logical operators

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.