Variables are named memory locations used to store data. These memory locations are reserved and can be manipulated by programs during run-time. By defining a variable, we allocate a memory location that can store various types of data. These data types define how much memory we are reserving out of the total allocated memory.
Below are some of the variable types generally used in programming:
Type | Description |
---|---|
char | Used to store one byte of data. The data type of this kind of variable is “integer”. |
int | Used to store whole numbers. |
float | Used to store fractional numbers with 6 to 7 decimal digits. |
bool | Used to store True or False values. |
double | Used to store floating point numbers with double the precision of floats. |