The Boolean Type

#include <stdbool.h>

Apart from the primitive types, we have boolean type.

Boolean means true/false, yes/no, 1/0

The Boolean Type

C has since added another type, the boolean type in the C99 standard version of C, as _Bool. It has also added the useful alias bool, (another name for _Bool,) as well as macros true and false to represent the values for convenience, but these require the inclusion of <stdbool.h>.

TypeDescription

_Bool

A boolean value represented in a 1-bit integer. Assigning anything non-0 to it is set to 1, considered true.

bool

true evaluates to 1; false evaluates to 0

Variable Declaration

// Declaring a bool variable with the name is_happy and set it to be true
bool is_happy = true; 

Last updated