Datatypes in C++
In this tutorial, we are going to learn about basic data types such as int, float, and char with the help of examples.
Data types are declarations for variables.
In C++ data type determines the size and data associated with variables.
- Here pay is a variable for data type int.
- Which determines that it can only store the integer value.
C++ Fundamental Data Types
||Size in bytes
||2 or 4
Lets discuss these datatypes one by one
1.Int datatype in C++
- It is used to specify integers.
- It has the size of 4 bytes.
- It can store the values from -2147483648 to 2147483647.
2.Float and double in C++
- Float and double is used to store floating point numbers such as 1.24,1123.5 and 1222.05 etc.
- Float has the size of 4 bytes.
- Double has the size of 8 bytes.
3.Char in C++
- char is used to store a Character.
- char has the size of 1 byte.
- char is enclosed in ' '.
4.Bool in C++
- A boolean value is stored in bool. bool has a 1 byte value and is found in conditional statements and loops.
- bool are used in conditional statements and loops.
5.Void in C++
- void is used to indicate that there is no data.
- bool has the size of 0 byte.
Note:We cannot declare the variables of type void