DATA TYPES IN C++ : A data type is used to indicate the type of data value stored in a variable. All C++ compilers support a variety of data types. This variety of data types allows the programmer to select the type appropriate to the needs of the application as well as the machine.
Types of data types in c++ :
1.Primary (fundamental) data types.
2.Derived data types.
3.User-defined data types
Primary data types :
Primary data types are pre-defined data types. There are three types of primitive data types:
1.integer data type
2.character data type
3.float point data type
4.Boolean data type
5.void data type
Integer data type :
This data type is used to store whole numbers. These numbers do not contain the decimal part. The size of the integer depends upon the world length of a machine (16-bit or 32-bit). On a 16-bit machine, the range of integer values is – 32,768 to +32,767.integer variables are declared by keyword int. C provides control over range of integer values and storage space occupied by these values through the data types: short int, int, long int in both signed and unsigned forms.
Signed integers : (16-bit machine): A signed integer uses 1 bit for sign and 15 bits for the magnitude of the number.
Unsigned integers : Unsigned integers use all 16 bits to store the magnitude. Stores numbers does not have any sign & Size qualifier and range of integer data type on a 16-bit and machine
Character data type :
(char) A single character can be defined as a character data type. Character data type occupies one byte of memory for storage of character. The qualifiers signed or unsigned can be applied on char data type. char is the key word used for declaring variables.
Floating Point Types :
Floating point number represents a real number with 6 digits precision occupies 4 bytes of memory. These are declared by the keyword float.
Double floating point data type occupies 8 bytes of memory giving 14 digits of precision. These are also known as double precision numbers. Variables are declared by keyword double long double refers to a floating point data type that is often more precise than double precision.
Boolean data type :
Boolean or logical data type is a data type, having two values (usually denoted true and false), intended to represent the truth values of logic and Boolean algebra. It is named after George Boole, who first defined an algebraic system of logic in the mid 19th century. The Boolean data type is the primary result of conditional statements, which allow different actions and change control flow depending on whether a programmer-specified Boolean condition evaluates to true or false.
Void type :
The void type has no values. This is usually used to specify the return type of functions. The type of the function said to be void when it does not return any value to the calling function. This is also used for declaring general purpose pointer called void pointer.
Derived data types :
Derived data type are defined with the help of pre-defined dat types, [Arrays , pointer and references] are derived data types.
User-defined data types :
The data types which are defined by the user are known as the user-defined data types.
[Structure,union,class and enumeration] are the user defined data types.