LOGBOOK

HELP

Quiz Entry - updated: 2026.07.10

How does C evaluate conditions (true/false)?

Any non-zero value counts as true and zero counts as false — C89 has no built-in boolean type at all.

// These are equivalent:
// True if a != 0
if (a)
// Explicit comparison
if (a != 0)

// True if b == 0
if (!b)
// Explicit comparison
if (b == 0)

No native true/false in C89:

// Common pattern:
#define true  1
#define false 0

// Or use stdbool.h (C99):
#include <stdbool.h>
bool flag = true;

Warning with #define true/false:

#define true 1
int a = 5;
// FALSE! 5 != 1, even though 5 is "truthy"
if (a == true)
// TRUE! Any non-zero is truthy
if (a)

Tip: Never compare against true. Just use if (a) or if (!a).

From Quiz: REVE1 / C Programming | Updated: Jul 10, 2026