C examples for Data Type:Introduction
Keyword | Variable Type | Range |
---|---|---|
char | Character (or string) | -128 to 127 |
int | Integer | -32,768 to 32,767 |
short | Short integer | -32,768 to 32,767 |
short int | Short integer | -32,768 to 32,767 |
long | Long integer | -2,147,483,648 to 2,147,483,647 |
unsigned char | Unsigned character | 0 to 255 |
unsigned int | Unsigned integer | 0 to 65,535 |
unsigned short | Unsigned short integer | 0 to 65,535 |
unsigned long | Unsigned long integer | 0 to 4,294,967,295 |
float | Single-precision floating-point | +/-3.4 * 10^38 to +/-3.4 * 10 ^ -38 |
double | Double-precision floating-point | +/-1.7 * 10 ^ -308 to +/-1.7 * 10 ^ 308 |
In all, C has really only four types of variables:
char int float double
What Signed and Unsigned Variables Can Hold
Signed | Range | Unsigned | Range |
---|---|---|---|
char | -128 to 127 | unsigned char | 0 to 255 |
int | -32768 to 32,767 | unsigned int | 0 to 65,535 |
long | -2,147,483,648 | unsigned long | 0 to 4,294,967,295 to 2,147,483,647 |