Data type in C++:
When we wish to store data
in a C++ program, such as a whole number or a character, we have to tell the
compiler which type of data we want to store. The data type will have
characteristics such as the range of values that can be stored and the
operations that can be performed on variables of that type. When programming, we store the variables in our
computer's memory, but the computer has to know what kind of data we want to
store in them, since it is not going to occupy the same amount of memory to
store a simple number than to store a single letter or a large number, and they
are not going to be interpreted the same way.
The C++ programming language identifies five
data types as standard data types:
·
Boolean
·
Character
·
Integer
·
Floating-point
"A type defines a set of values and a set of
operations that can be applied on those values. The set of values for each type
is known as the domain for that type."
List of Data type:
Name
|
Description
|
Size*
|
Range*
|
char
|
Character or small
integer.
|
1byte
|
signed: -128 to 127
unsigned: 0 to 255 |
short int(short)
|
Short Integer.
|
2bytes
|
signed: -32768 to
32767
unsigned: 0 to 65535 |
int
|
Integer.
|
4bytes
|
signed: -2147483648 to
2147483647
unsigned: 0 to 4294967295 |
long int (long)
|
Long integer.
|
4bytes
|
signed: -2147483648 to
2147483647
unsigned: 0 to 4294967295 |
bool
|
Boolean value. It can
take one of two values: true or false.
|
1byte
|
true or false
|
float
|
Floating point number.
|
4bytes
|
+/- 3.4e +/- 38 (~7
digits)
|
double
|
Double precision
floating point number.
|
8bytes
|
+/- 1.7e +/- 308 (~15
digits)
|
long double
|
Long double precision
floating point number.
|
8bytes
|
+/- 1.7e +/- 308 (~15
digits)
|
0 comments:
Post a Comment