30 Introduction to C++ Programming and Graphics
The statement:
int a = 023;
with a leading zero (0), implies
a=2× 81 +3× 80.
The statement:
int a = 0xA4;
with a leading zero (0) followed byximplies
a=10× 161 +4× 160.
Boolean variables
A Boolean variables can be eitherfalseortrue. When a Boolean vari-
able is printed, it appears as 1 or 0, respectively, for true and false.
The following statements declare and initialize the Boolean variablehot:
bool hot;
hot = true;
An equivalent statement is:
bool hot = true;
Boolean variables are useful for assessing states and making logical decisions
based on deduced outcomes.
Characters
A single character is encoded according to the ASCII protocol described
in Appendix D. The following statements declare and initialize a character:
char a;
a = 66;
In compact form:
char a = 66;