Datatypes in C
DATATYPE: What type of data is given into a variable is called datatype.
Different type of datatypes:
- Primitive datatype
- Derived datatypes
PRIMITIVE DATATYPE: These are built in very commonly used datatypes they are char ,int,float,void.
INTEGER DATATYPE:
Every data type has signed and unsigned datatypes.
Type | Size(bytes) | Range of values |
int | 2 | -32,768 to 32767 |
signed int
| 2 | -32768 to 32767 |
unsigned int | 2 | 0 to 65535 |
short int | 1 | -128 to 127 |
signed short int
| 1 | -128 to 127 |
unsigned short int | 1 | 0 to 255 |
long int | 4 | -2,147,483,648 to 2,147,483,647 |
signed long int
| 4 |
-2,147,483,648 to 2,147,483,647
|
unsigned long int | 4 | 0 to 4,294,967,295 |
Float datatype
This datatype used to store decimal point values.
Type | Size(bytes) | Range |
Float | 4 | 3.4E-38 to 3.4E+38 |
double | 8 | 1.7E-308 to 1.7E+308 |
long double | 10 | 3.4E-4932 to 1.1E+4932 |
Character type
Character types are used to store character values.
Type | Size(bytes) | Range |
char or signed char | 1 | -128 to 127 |
unsigned char | 1 | 0 to 255 |
void type
void type means no value. This is usually used to specify the type of functions which returns nothing.
This is used in pointers.
DERIVED DATATYPES:
Derived datatypes are struct , union.
These are used to create a datatypes based on user choice.
SIZE OF operator is used to return size a variable occupies.