The four fundamental data types are:
Character
Integer
float
Double
Character
char is a data type used for storing a single character. If we store an integer on this data type it will correspond to ASCII character (65 for letter A).
Syntax
char variable_name = value;
char takes one byte from memory.
Type | Bytes | Range |
char | 1 | -127 to 127 |
unsigned char | 1 | 0 to 255 |
signed char | 1 | -127 to 127 |
Integer is a datatype which stores a whole number (no fractional part), the number can be positive or negative.
Syntax
int variable_name = value;
Type | Bytes | Range |
int | 2 | -32,767 to 32,767 |
unsigned int | 2 | 0 to 65,535 |
signed int | 2 | -32,767 to 32,767 |
short int | 2 | -32,767 to 32,767 |
unsigned short int | 2 | 0 to 65,535 |
signed short int | 2 | -32,767 to 32,767 |
long int | 4 | -2,147,483,647 to 2,147,483,647 |
signed long int | 4 | -2,147,483,647 to 2,147,483,647 |
unsigned long int | 4 | 0 to 4,294,967,295 |
Float stores number with decimal values. It takes 4 bytes of memory.
Syntax
float variable_name = value;
Double
Double can hold larger number with a high degree of precision. It takes 8 bytes of memory.
Share if you liked this Post using your favorite sharing service:
Subscribe Updates, Its FREE!
0 comments:
Post a Comment