data types

15
DATA TYPES

Upload: nicole-ynne-estabillo

Post on 13-Jan-2017

36 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Data Types

DATA TYPES

Page 2: Data Types

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

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

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
Page 6: Data Types
Page 7: Data Types
Page 8: Data Types

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

Text, such as “Hello World!”, is also referred to as a literal value because the text itself is displayed.

Page 10: Data Types

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

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

Integer Data Types

The following are the examples of valid integers

Page 13: Data Types

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

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