Using bool data type
In C
, like any other programming languages, has various data types. These include the primitives such as int
and real
.
Another data type of C
is bool
. However, you cannot directly use it. In order to use this data type, we have to import the header stdbool.h
.
Sample
Below is the sample implementation:
#include <stdio.h>
#include <stdbool.h>
int main() {
bool completed = true;
printf("%i\n", completed);
return 0;
}
This will print the integer 1
which represents true
. false
value is represented by 0
and all other non-zero values are `true.