What is Data types in c
1 minute read
What is Data types in c
Data types specify how we can enter data into our programs and which type of data we enter. C language has some predefined set of data types to manage different types of data that we can use in our program.
There are three types of data types in C language:
1. Primary data types:
There are some fundamental data types in C namely integer(int), floating point(float), character(char) and void.
2. Derived data types:
Derived data types are also primary datatypes but a little twisted or grouped together like array, stucture, union and pointer. These are discussed in details later.
3. User defined data types:
User defined data types are defined by user like type deft, enum.
Data type determines the type of data a variable will store. If a variable x is declared as int. it means x can hold integer values.
Integers are used to store whole numbers.
Type | Size(bytes) | Range |
int or signed int | 2 | -32,768 to 32767 |
unsigned int | 2 | 0 to 65535 |
short int or signed short int | 1 | -128 to 127 |
unsigned short int | 1 | 0 to 255 |
long int or signed long int | 4 | -2,147,483,648 to 2,147,483,647 |
unsigned long int | 4 | 0 to 4,294,967,295 |
Floating point type
Floating types are used to store real numbers.
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 characters value.
Type | Size(bytes) | Range |
char or signed char | 1 | -128 to 127 |
unsigned char | 1 | 0 to 255 |