In C language, !x represents logical NOT operation, converting true value to false value, and false value to true value; Processor macro implementation, only works with non-negative integers.
##!The difference between x and x! in C language
Direct answer:
!x represents logical NOT operation, x! represents factorial operation.Detailed explanation:
<code class="c">int x = 0; printf("%d\n", !x); // 输出 1 (真)</code>
<code class="c">int x = 5; printf("%d\n", x!); // 输出 120 (5 x 4 x 3 x 2 x 1)</code>
Difference summary:
Purpose | Result | |
---|---|---|
logical negation | True value negation | |
Factorial | The product of natural numbers |
There is no built-in factorial operator in C language. The
x!The factorial operation only works on non-negative integers.
The above is the detailed content of The difference between !x and x! in c language. For more information, please follow other related articles on the PHP Chinese website!