Skip to content

Data Types in C & C++

Type of Primary Data

A fundamental or primitive data type is a form of built-in data that a programming language offers for use in the construction of more sophisticated data structures. Four data types that participate in several data formats are considered primitive data types.

* Integer *

An integer data type is used to represent variables that have numeric values or have no values at all. Such data types without values may have their range designated as "short" or "long" depending on the requirements of the programme. The keyword "int" indicates that a value is of the integer data type.

* Character *

Characters of a specific length are included in character data types. Anything from letters, numbers, and symbols are permitted. An integral-type value can only be contained in char, which has a 1 byte capacity limit. Char is a data type.

* Floating Point *

Floating-point data types are used to represent real numbers. The keyword "float" indicates that a value is of the floating-point data type. The keyword "double" indicates that a value is of the double-precision floating-point data type. The keyword "long double" indicates that a value is of the long double-precision floating-point data type.

* Boolean *

Boolean data types are used to represent variables that have a value of either true or false. The keyword "bool" indicates that a value is of the boolean data type.

* Type of Derived Data *

Derived data types are data types that are constructed from the primitive data types. The derived data types are arrays, structures, unions, and pointers.

* Array *

An array is a collection of data items of the same type. The data items are stored in contiguous memory locations. The array is a derived data type.

* Structure *

A structure is a collection of data items of different types. The data items are stored in contiguous memory locations. The structure is a derived data type.

* Union *

A union is a collection of data items of different types. The data items are stored in the same memory location. The union is a derived data type.

* Pointer *

A pointer is a variable that stores the address of another variable. The pointer is a derived data type.

Type of Abstract Data

Abstract data types are data types that are defined by their behaviour from the point of view of the user. The abstract data types are functions, files, and records.

* Function *

A function is a group of statements that perform a specific task. The function is an abstract data type.

* File *

A file is a collection of data items of the same type. The data items are stored in a file. The file is an abstract data type.

* Record *

A record is a collection of data items of different types. The data items are stored in a record. The record is an abstract data type.

Type of User-Defined Data

User-defined data types are data types that are defined by the user. The user-defined data types are enumerated, typedef, and class.

Enumerated

An enumerated data type is a data type that is defined by a list of names called enumerators. The enumerated data type is a user-defined data type.

Typedef

A typedef data type is a data type that is defined by a keyword. The typedef data type is a user-defined data type.

Class

A class is a data type that is defined by a keyword. The class is a user-defined data type.

Type of Special Data

Special data types are data types that are defined by the compiler. The special data types are void, auto, register, static, extern, mutable, and volatile.

Void

A void data type is a data type that is defined by the compiler. The void data type is a special data type.

Auto

An auto data type is a data type that is defined by the compiler. The auto data type is a special data type.

Register

A register data type is a data type that is defined by the compiler. The register data type is a special data type.

Static

A static data type is a data type that is defined by the compiler. The static data type is a special data type.

Extern

An extern data type is a data type that is defined by the compiler. The extern data type is a special data type.

Mutable

A mutable data type is a data type that is defined by the compiler. The mutable data type is a special data type.

Volatile

A volatile data type is a data type that is defined by the compiler. The volatile data type is a special data type.

Type of Data Type

Data types are classified into two types: built-in data types and user-defined data types.

Built-in Data Types

Built-in data types are data types that are defined by the programming language. The built-in data types are primitive data types, derived data types, abstract data types, and special data types.

User-Defined Data Types

User-defined data types are data types that are defined by the user. The user-defined data types are enumerated data types, typedef data types, and class data types.

Type of Data Type Modifier

Data type modifiers are used to modify the data types. The data type modifiers are signed, unsigned, short, long, and const.

Signed

A signed data type modifier is used to modify the data types. The signed data type modifier is a data type modifier.

Unsigned

An unsigned data type modifier is used to modify the data types. The unsigned data type modifier is a data type modifier.

Short

A short data type modifier is used to modify the data types. The short data type modifier is a data type modifier.

Long

A long data type modifier is used to modify the data types. The long data type modifier is a data type modifier.

Const

A const data type modifier is used to modify the data types. The const data type modifier is a data type modifier.

Type of Data Type Qualifier

Data type qualifiers are used to qualify the data types. The data type qualifiers are volatile and restrict.

Volatile

A volatile data type qualifier is used to qualify the data types. The volatile data type qualifier is a data type qualifier.

Restrict

A restrict data type qualifier is used to qualify the data types. The restrict data type qualifier is a data type qualifier.