Data Types in C++ | AsgarTech

 Data Types in C++ | AsgarTech



In C++, a data type is an attribute that specifies the type of data that a variable can hold. C++ supports several built-in data types, including:

Integer types: These are used to represent whole numbers. They can be signed (can represent negative and positive numbers) or unsigned (can only represent non-negative numbers). Examples include int, short, long, and long long.

Floating-point types: These are used to represent real numbers with decimal places. Examples include float and double.

Character types: These are used to represent individual characters. Examples include char and wchar_t.

Boolean type: This data type represents true/false values. It can only take two values: true or false.

Void type: This data type represents absence of type. Functions with return type void return no value.

Enumerated types: These are user-defined data types that consist of a set of named integer values.

Arrays: These are used to hold a collection of elements of the same data type.

Pointers: These are used to store the memory address of a variable.

In addition to these built-in data types, C++ also allows programmers to define their own custom data types using structures, classes, and unions.


No comments: