• Register
100 points
7 2
Welcome to Kodlogs, programming questions and answer website.

The bool function is form of data type that is basically used to validate data as either true or false. The Boolean provides better control in testing certain situations and provides conveniences to C++ programmers. The symbols used to denote true in Boolean are integer value 1 while 0 represents false. 


The bool function also contains the Boolean expression that is used as a comparison operator such as greater than (>); this operator is used to find out if the expression/ variable is true. Once the Boolean is initialized for this operator it returns an output of 1 if the function is true. 


Int x=5

Int y= 3, 

Then the Boolean expression will be; cout<<(x>y); this returns 1 because 5 is greater than 3. 

A Similar expression can also apply to less than (<) in the Boolean function. 

Another operator that applies to bool is equal to (=) to evaluate the expression. 



Int y=6 

The function will be; cout<<(6=6) returns 1 because it is true. However, a function like cout <<6=10) will return zero because 6 is not equal to 10. 

The conclusion is that Booleans are the basis for all types of comparison in C++ 

Hope this helps.

100 points
7 2