Tsallaka zuwa abun ciki
Justice Tech School

Booleans

C has no built-in boolean in old code: 0 is false and anything else is true. With #include <stdbool.h> you can use bool, true and false, which make code clearer.

Example
bool isAdult = 20 >= 18;
bool hasTicket = false;
printf("%d\n", isAdult && hasTicket);
printf("%d\n", isAdult || hasTicket);
printf("%d\n", !hasTicket);

Result

0
1
1

Exercise

Which value counts as false in C?

if () { } /* never runs */

Quiz Test

Which header gives you bool?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.