5.2 Relational operators and logical operators
One, logical operators
Logical operators refer to the use of formal logic principles to establish the relationship between the number of symbols. The logical operators of Turbo C are as follows:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
operator function
─────────────────────────────
&& Logic and
|| Logical OR
! Logical non
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Second, relational operators
A relational operator is a symbol that compares the size of two operands. The relational operators of Turbo C are as follows:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
operator function
─────────────────────────────
> Greater than
>= is greater than or equal to
< less than
<= less than or equal
= = equals
!= is not equal to
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
The key to relational and logical operators is true (true) and False (false) concepts. True in Turbo C can be any value that is not 0, and false is 0. When using relational operators and logical operator expressions, returns 1 if the expression is true (that is, true), or 0 if the expression is false (that is, false).
For example:
100>99 return 1
10> (2+10) return 0
!1&&0 return 0
In the example of the expression!1&&0, first of all! 1 and first 1&&0 will be equal to a different result, then what is the priority? This is provided for in Turbo C. Precedence about operators is described later in this section.
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.