In C language, the difference between !a and a! is: !a is a logical NOT operation, converting true values into false, and false values into true; and a! is a factorial operation, calculating the number a factorial.
The difference between !a and a! in c language
Direct answer:
In C language, !a
represents logical NOT operation, and a!
represents factorial operation.
Detailed explanation:
Logical NOT operation (!a):
!0
The result is 1 (true), !1
The result is 0 (false). Factorial operation (a!):
5!
The result is 120, which is 1 x 2 x 3 x 4 x 5. Example:
<code class="c">int a = 5; printf("!a = %d\n", !a); // 输出0,因为5是非0值,因此其非值为假(0) printf("a! = %d\n", a!); // 输出120,因为5的阶乘是120</code>
Note:
The above is the detailed content of The difference between !a and a! in c language. For more information, please follow other related articles on the PHP Chinese website!