C++ Data Types

A data type specifies the type of data that a variable can store such as integer, floating, character etc. There are several kinds of built-in data types. These are often called fundamental data types or primitives.

The integer (whole number) types are short, int, long, and long. The float, double and long double types are floating-point (real number) types. The char type holds a single character and the bool type contains either a true or false value. Cpp Data typews 1

There are 4 types of data types in C++ language.

Types Data Types
Basic Data Type int, char, float, double, etc.,
Derived Data Type array, pointer, etc.,
Enumeration Data Type enum
User Defined Data Type structure

Basic Data Types

In C++, the exact size and range of data types are not fixed. The size and range of these data types may vary between processor types and compilers. However, in all cases a character is 1 byte. The memory size of basic data types may change according to 32 or 64 bit operating system.

The basic data types are integer-based and floating-point based. C++ language supports both signed and unsigned literals.

Below are the data types Defined by the ANSI/ISO C standard.

Data Types Typical Size in Bits Minimal Range
char 1 byte -128 to 127
signed char 1 byte -128 to 127
unsigned char 1 byte 0 to 127
short 2 byte -32,768 to 32,767
signed short 2 byte -32,768 to 32,767
unsigned short 2 byte 0 to 32,767
int 2 byte -32,768 to 32,767
signed int 2 byte -32,768 to 32,767
unsigned int 2 byte 0 to 32,767
short int 2 byte -32,768 to 32,767
signed short int 2 byte -32,768 to 32,767
unsigned short int 2 byte 0 to 32,767
long int 4 byte -2,147,483,647 to 2,147,483,647
signed long int 4 byte -2,147,483,647 to 2,147,483,647
unsigned long int 4 byte 0 to 4,294,967,295
float 4 byte IE-37 to IE+37, with six digits of precision
double 8 byte IE-37 to IE+37, with ten digits of precision
long double 10 byte IE-37 to IE+37, with ten digits of precision
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +