Data Types in C++

Default Image

While writing source code in any
language, you need to use several variables to store information.
Variables are reserved memory locations to store values. This means that
when you create a variable you reserve some space in memory. You may
like to store data of different data types like character, wide
character, integer, floating point, double floating point, Boolean etc.
Based on the data type of a variable, the translator allocates memory
and decides what can be stored in the reserved memory.

             In a programme we declare
data types for variables before using them. The values or data used in a
programme may be of different types. In C++ each variable is associated
with a specific data type. There are two different types of data:
standard and user defined data types.


        Standard data types:


Data types that are defined by the developers of language as part of language are called standard data types.













































































Data Type Data Bit Width Data Range
char

1byte


-127 to 127 or 0 to 255
unsigned char

1byte


0 to 255
signed char

1byte


-127 to 127
int

4bytes


-2147483648 to 2147483647
unsigned int

4bytes


0 to 4294967295
short int

2bytes


-32768 to 32767
unsigned short int
0 to 65,535
signed short int
-32768 to 32767
long int

4bytes


-2,147,483,648 to 2,147,483,647
signed long int

4bytes


-2,147,483,648 to 2,147,483,647
float

4bytes


+/- 3.4e +/- 38 (~7 digits)
double

8bytes


+/- 1.7e +/- 308 (~15 digits)
long double

8bytes


+/- 1.7e +/- 308 (~15 digits)
wchar_t

2 or 4 bytes


1 wide character

Read Count: 3 times

Comments

No comments yet.

Leave a Comment