Home  >  Article  >  Backend Development  >  !What is equal to a in C language?

!What is equal to a in C language?

下次还敢
下次还敢Original
2024-04-29 19:24:141147browse

In C language, the ! operator represents the logical NOT operation, which converts the operand to a Boolean value and returns its opposite: 0 (false) if the operand is non-zero. If the operand has a zero value, returns 1 (true).

!What is equal to a in C language?

!a is equal to what in C language

In C language,! operator represents the logical NOT operation, which converts the operand to a Boolean value and returns its opposite value.

The calculation rules for logical NOT operations are:

  • If the operand is a non-zero value, 0 (false) is returned
  • If The operand has a zero value, then 1 (true) is returned

So, for variable a:

  • if a is not If !a is zero (not equal to 0), then
  • !a
  • returns 0If a is zero (equal to 0), then
  • !a
returns 1

Example:

Assume the value of

a

is 5, then: <pre class="brush:php;toolbar:false">&lt;code&gt;!a = !(5) // 5 不等于 0 !a = 0 // 返回 0(假)&lt;/code&gt;</pre>On the contrary, if

a# The value of ## is 0, then: ###
<code>!a = !(0)  // 0 等于 0
!a = 1    // 返回 1(真)</code>

The above is the detailed content of !What is equal to a in C language?. 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