data types
TRANSCRIPT
![Page 1: Data Types](https://reader035.vdocuments.us/reader035/viewer/2022070515/5877da031a28abaa6c8b5f83/html5/thumbnails/1.jpg)
DATA TYPES
![Page 2: Data Types](https://reader035.vdocuments.us/reader035/viewer/2022070515/5877da031a28abaa6c8b5f83/html5/thumbnails/2.jpg)
Data type is defined as a set of values and a set of operations.
For example, the set of all integer (whole) numbers constitutes a set of values.
![Page 3: Data Types](https://reader035.vdocuments.us/reader035/viewer/2022070515/5877da031a28abaa6c8b5f83/html5/thumbnails/3.jpg)
This set of numbers, however, doesn’t constitute a data type until a set of operations is included.
These operations, of course, are the familiar mathematical and comparison operations. The combination of a set of values plus operations results in a true data type.
![Page 4: Data Types](https://reader035.vdocuments.us/reader035/viewer/2022070515/5877da031a28abaa6c8b5f83/html5/thumbnails/4.jpg)
A class data type (referred to as a “class,” for short) is a programmer-created data type.
A built-in data type is provided as an integral part of the programming language. Built-in data types are also referred to as primitive types.
![Page 5: Data Types](https://reader035.vdocuments.us/reader035/viewer/2022070515/5877da031a28abaa6c8b5f83/html5/thumbnails/5.jpg)
![Page 6: Data Types](https://reader035.vdocuments.us/reader035/viewer/2022070515/5877da031a28abaa6c8b5f83/html5/thumbnails/6.jpg)
![Page 7: Data Types](https://reader035.vdocuments.us/reader035/viewer/2022070515/5877da031a28abaa6c8b5f83/html5/thumbnails/7.jpg)
![Page 8: Data Types](https://reader035.vdocuments.us/reader035/viewer/2022070515/5877da031a28abaa6c8b5f83/html5/thumbnails/8.jpg)
A literal value means the value identifies itself or constant. For example, all numbers, such as 2, 3.6, and -8.2, are referred to as literal values because they literally display their values.
![Page 9: Data Types](https://reader035.vdocuments.us/reader035/viewer/2022070515/5877da031a28abaa6c8b5f83/html5/thumbnails/9.jpg)
Text, such as “Hello World!”, is also referred to as a literal value because the text itself is displayed.
![Page 10: Data Types](https://reader035.vdocuments.us/reader035/viewer/2022070515/5877da031a28abaa6c8b5f83/html5/thumbnails/10.jpg)
Integer Data Types
C++ provides nine built-in integer data typesThe int Data Type The values supported by the int data type are whole numbers, which are mathematically known as integers.
![Page 11: Data Types](https://reader035.vdocuments.us/reader035/viewer/2022070515/5877da031a28abaa6c8b5f83/html5/thumbnails/11.jpg)
Integer Data Types
An integer value consists of digits only and can optionally be preceded by a plus (+) or minus (-) sign. Therefore, an integer value can be the number 0 or any positive or negative number without a decimal point.
![Page 12: Data Types](https://reader035.vdocuments.us/reader035/viewer/2022070515/5877da031a28abaa6c8b5f83/html5/thumbnails/12.jpg)
Integer Data Types
The following are the examples of valid integers
![Page 13: Data Types](https://reader035.vdocuments.us/reader035/viewer/2022070515/5877da031a28abaa6c8b5f83/html5/thumbnails/13.jpg)
Integer Data Types
Examples show, integers can contain an explicit sign. However, no commas, decimal points, or special symbols, such as the dollar sign are not allowed, as in these examples of invalid integers:
![Page 14: Data Types](https://reader035.vdocuments.us/reader035/viewer/2022070515/5877da031a28abaa6c8b5f83/html5/thumbnails/14.jpg)
The Escape Character
(\) has a special meaning in C++ as the escape character. When a backslash is placed in front of a group of characters, it tells the compiler to escape from the way these characters are normally interpreted.
![Page 15: Data Types](https://reader035.vdocuments.us/reader035/viewer/2022070515/5877da031a28abaa6c8b5f83/html5/thumbnails/15.jpg)