A boolean is a data type in the C Standard Library which can store true or false. Every non-zero value corresponds to true while 0 corresponds to false.
C doesn’t natively support boolean type. In C, zero means false. And other values are true. For example, all the numbers which are not zero are true.
The boolean works as it does in C++. However, if you don’t include the header file stdbool.h, the program will not compile.
Declaration
To declare a variable as a boolean use:
bool variable_name = true;Example:
#include
#include
int main()
{
bool a = true;
if(a)
printf("Its ture");
return 0;
}
0 Comments