Boolean Type
Boolean type is declared
with the keyword bool. It has two possible values: true and false.
Its default value is false. It is used most often to store the
calculation result of logical expressions.
Boolean Type – Example
Consider an example in which we declare several variables from the already known types, initialize them, compare them and print the result on the console:
In the example above, we declare two variables of type int, compare them and assign the result to the bool variable greaterAB. Similarly, we do the same for the variable equalA1. If the variable greaterAB is true, then A > B is printed on the console, otherwise A <= B is printed.
0 Comments