Data comes in various types: numerical, alphabetical, Boolean, and so on. The total number of data types is unlimited since it's possible for programmers to define their own kinds of data. But C++ provides a number of fundamental types that tend to be used by most programs. The following subsections list some of the most common data types encountered in C++.
Remember, C++ is case sensitive. Thus, such words as "int," "INT," and "Int" are treated as separate items.
In C++ a keyword is a reserved word. There are certain reserved words in C++, some of which are listed in Appendix E, and programmers can only use those words to mean one thing, as we shall see.
Integers are whole numbers like −5, 0 and 7. They do not have fractional components, such as 5.5, 7.3, −3.2. C++ represents integers with the keyword int. Each time int is included in a C++ program, it means an integer value. Later sections demonstrate how integer data types are used.
Float means floating-point number and is used to define numerical data, which may or may not include a fractional value, and thus may or may not have a decimal point. Floats require more memory than integers, and are implemented in C++ using the float keyword.
Booleans are numerical data whose value can be either 1 or 0, corresponding to true or false, respectively. Booleans are indicated in C++ by the keyword bool.
Characters are letters and other symbols that can appear on a keyboard, such as "a," "b," and "@." Ultimately, each character corresponds to a number, but the character data type stores data in the context of a character rather than a number. The keyword for a character in C++ is char.