Complete Computer Knowledge Portal

Thursday, July 4, 2013

Fundamental Data Types in C++

These are those data types that are not composed of any other data types. C++ makes use of following five fundamental data types

1) Char
: This data type is used to store basic character sets. It is sometimes referred to as integer type because letters and symbols are represented in memory by the associated number codes. Table given below illustrates various types of character types along with their range.

Character Type
Size in Bytes
Minimal Range
Char
1
-128 to 127
Unsigned Char
1
0 to 255
Signed Char
1
-128 to 127

2) Int: These are whole numbers and do not have fractional part. e.g. 30, 45 etc. Identifier declared as int can not have fractional value. Integer value can be positive or negative. Below given table illustrates various types of integers along with their range.

Integer Type
Approximate size in bytes
Minimal Range
Short
2
-32768 to 32767
Unsigned Short
2
0 to 65,535
Signed Short
2
-32768 to 32767
Int
2
-32768 to 32767
Unsigned Int
2
0 to 65,535
Signed Int
2
-32768 to 32767
Long
4
-2,147,483,648 to 2,147,483,647
Unsigned Long
4
0 to 4,294,967,295
Signed Long
4
-2,147,483,648 to 2,147,483,647

3) Float : This type of data type is used for storing floating point numbers. Fractional Numbers are those which are having fractional part. E.g.234.45. Decimal point identifies that this is a float number not an Integer. Table given below illustrates various types of float data type and their range.

Data Type
Size in Bytes
Minimal Range
Float
4
3.4 X 10-38 to 3.4 X 1038 - 1
Double
8
1.7 X10-308 to 1.7 X 10308 - 1
Long Double
10
3.4 X 10-4932 to 3.4 X 104932 - 1

4) Double: This data type is also used to store floating numbers but it is treated as different from float because it takes double space than float and can store floating point numbers that have larger range and precision.

5) Void Data Type: This data type is used to specify empty set of values. This data type is used as return type for functions that do not return any value.

No comments:

Post a Comment