C has a concept of 'data types' which are used to define a variable before its use. C compilers support four fundamental data types, namely integer (int), character (char), floating point (float), and double-precision floating point (double). Like integer data type, other data types also offer extended data types such as long double and signed char.
Data
Type
Data Type of a variable tell to the compiler
- Name of variable
- Which type of value that variable can hold
- How much memory space it reserve
1. Primary data type or predefined data type or Fundamental data type - are those data type that are defined in c already.
Data Type
|
Used for
|
Size(in Byte)
|
Range
|
Format
|
Int | Integer | 2 | -32768 to 32767 |
%d
|
Char | Character | 1 | -128 to 127 |
%c
|
Float | Single precision floating point number | 4 | -3.4e38 to +3.4e38 |
%f
|
Double | double precision floating point number | 8 | -1.7e308 to +1.7e308 |
%lf
|
Void | - | - | - |
0
|
Data Type Modifiers –There are four modifiers available.
- Signed
- Unsigned
- Short
- Long
Data
Type
|
Size(in Byte)
|
Range
|
Format
|
signed char | 1 | -128 to + 127 |
%c
|
unsigned char | 1 | 0 to 255 |
%c
|
signed int | 2 | -32768 to +32767 |
%d
|
unsigned int | 2 | 0 to 65535 |
%u
|
short signed int | 2 | -32768 to +32767 |
%d
|
short unsigned int | 2 | 0 to 65535 |
%u
|
long double | 10 | -1.7e4932 to +1.7e4932 |
%Lf
|
2. Derived data type - are those data type that are derived by predefined data type.
Example-Array, pointer
3. User defined data type - are those data type that are defined by the user itself.
Example-struct, union