!What is equal to a in C language?

下次还敢
Release: 2024-04-29 19:24:14
Original
1145 people have browsed it

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: <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">&lt;code&gt;!a = !(5) // 5 不等于 0 !a = 0 // 返回 0(假)&lt;/code&gt;</pre><div class="contentsignin">Copy after login</div></div>On the contrary, if

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

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!

Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template