#include <stdbool.h> // Header-file for boolean data-type.
int main() {
bool x=false; // Declaration and initialization of boolean variable.
if (x==true) { // Conditional statement.
printf("The value of x is true");
} else {
printf("The value of x is false");
}
return 0;
// Output: The value of x is false
}
The C99 standard for C language supports bool variables.
Unlike C++, where no header file is needed to use bool,
a header file “stdbool.h” must be included to use bool in C.
If we save the below program as .c, it will not compile,
but if we save it as .cpp, it will work fine.
#include<stdbool.h>