These are the types of data that the variable can hold. For example, data 10 and 100.5 are the data of different types. Data 10 is an integer number(i.e whole number) while 100.5 is a fractional number. There are other varieties of data types supported by C++, each of which may be represented differently within the computer’s memory. the variety f data type available allows the programmer to select the type needed by the application.
Basically, Data types have three classes.
- Primary data types
- User-defined data types
- Derived data types
Primary Data Types:
Primary Data types are categorized into five types:
- int: Variables that hold an integer value
int code_help_pro = 100;
- char: hold characters such as ‘A’, ‘b’, ‘V’
char code_help_pro = 'Y';
- bool: Store a boolean value i.e true or false
bool code_help_pro = true;
- double: hold a double-precision floating-point value
double code_help_pro = 100.9999;
- float: Store double-precision floating-point value
float code_help_pro = 100.3;
|Data Type||Category||Range||Memory Space (Byte)|
|Integer||int short signed short unsigned signed unsigned long signed long unsigned||-32768 to +32767 -32768 to +32767 0 to 65535 -32768 to +32767 0 to 65535 -2147483648 to 2147483647 0 to 4294967295||2 2 2 2 2 4 4|
|Float||float||3.4 X 10-38 to 3.4 X 10+38||4|
|double||double long double||1.7 X 10-308 to 1.7 X 10+308 3.4 X 10-4932 to 1.1 X 10+4932||8 10|
|char||signed char unsigned char||-128 to +127 0 to 255||1 1|
User-defined Data Types:
User-defined data types are categorized into three types in C++:
We will cover User-defined data types in the next chapter. In this topic, Just remember that, These fall under User-defined data types.
Derived Data Types:
Derived data types are categorized into three types in C++:
We will cover Derived data types in the next chapter. These are huge topics in C++. In this topic, Just remember that, These fall under User-defined data types.