C++ Data Types


Data Types in C++

Data types are used to define a variable. Data types represents the type of information present in a variable. Data types are the keywords, which are used for assigning a type to a variable.

Different Data Types available in C++

Value Types

Integer Type : Integer data type are like whole numbers, they also include negative numbers but does not support decimal numbers.

TypeStorage sizeValue range
int2 or 4 bytes-32,768 to 32,767 or -2,147,483,648 to 2,147,483,647
unsigned int2 or 4 bytes0 to 65,535 or 0 to 4,294,967,295
short2 bytes-32,768 to 32,767
unsigned short2 bytes0 to 65,535
long4 bytes-2,147,483,648 to 2,147,483,647
unsigned long4 bytes0 to 4,294,967,295

Float-point Type : Float data type allows user to store decimal values in a variable.

TypeStorage sizeValue rangePrecision
float4 byte1.2E-38 to 3.4E+386 decimal places
double8 byte2.3E-308 to 1.7E+30815 decimal places
long double10 byte3.4E-4932 to 1.1E+493219 decimal places

Character Type : Character data type is used to store only one letter, digit, symbol at a time.

TypeStorage sizeValue range
char1 byte-128 to 127 or 0 to 255
unsigned char1 byte0 to 255
signed char1 byte-128 to 127

Reference Types

  • Array : Array is a collection of similar data type. A single variable can hold only one value at a time, If we want a variable to store more than one value of same type we use array. More info
  • Pointers : A normal variable is used to store value. A pointer variable is used to store address / reference of another variable. More info

Related topics