Data types specify how we enter data into our programs and what type of data we enter. C language has some predefined set of data types to handle various kinds of data that we use in our program. Size of variables, constants and array are determined by data types.
C language supports 4 different type of data types :
C language supports 4 different type of data types :
- Basic Data Types : These are fundamental data types in C namely : Integer types, Floating-Point types
- Void Data Type : void
- Derived Data Types : They include (a) Pointer types, (b) Array types, (c) Structure types, (d) Union types and (e) Function types
- Enumeration Data Type : enum
Types
Data Types
Basic data types Integer types, Floating types
Void data type void
Derived data type pointer, array, structure, union
Enumeration data type enum
Integer Types :
Types
|
Data Types
|
Basic data types | Integer types, Floating types |
Void data type | void |
Derived data type | pointer, array, structure, union |
Enumeration data type | enum |
Integer Types :
Integer type consists int and char data type. Storage size and Range are given below of these data types -
- Integer (int) : Integer are used to store whole numbers.The storage size of int data type is 2 or 4 or 8 bytes. It varies upon the processor in the CPU that we use. If we are using 16 bit processor, 2 bytes of memory will be allocated for int data type.
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
- Integer (int) : Integer are used to store whole numbers.The storage size of int data type is 2 or 4 or 8 bytes. It varies upon the processor in the CPU that we use. If we are using 16 bit processor, 2 bytes of memory will be allocated for int data type.
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 |
- Character (char) : Character types are used to store characters value. It allows a variable to store only one character.
Type | Size(bytes) | Range |
---|---|---|
char or signed char | 1 | -128 to 127 |
unsigned char | 1 | 0 to 255 |
Floating Types :
Floating type consists float and double data type. Storage size and Range are given below of these data types -
- Float (float) : float data type allows a variable to store decimal values.
- Double (double) : double data type is same as float which allows up-to 10 digits after decimal.
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 |
Void Data Type :
void type means no value. This is usually used to specify the type of functions.
- Function returns as void
- Function arguments as void
- Pointers to void
Enumeration :
Enumeration data type consists of named integer constant as a list. It start with 0 by default and value is incremented by 1 for sequential identifier in the list.
Syntax :
enum identifier [optional {enumerator-list}];