Does the C standard explicitly indicate truth value as 0 or 1?

前端 未结 7 1532
日久生厌
日久生厌 2020-12-08 06:14

We know that any numbers that are not equal to 0 are viewed as true in C, so we can write:

int a = 16;

while (a--)
    printf(\"%d         


        
7条回答
  •  旧巷少年郎
    2020-12-08 06:54

    It happened because of the Relational Operators in your printf statement.

    Operator == and operator !=

    Since (0 == 0) holds true so, it gives a value 1

    whereas, (0 != 0) doesn't hold true so, gives a value 0 .

提交回复
热议问题