Data Types in C Language
'C' language is rich in its data types. Data is a group of characters. The variety of data type available to allow the programmer to select the type appropriate to needs of the application as well as the machine. The data types have four classes in 'C' language
1. Primary (fundamental) Data type
2. User defined Data type
3. Derived Data type
4. Empty Data set
Primary (Fundamental) Data Type
All "C' compilers supports four fundamental data types namely
(1) integer (int)
(2) character (char)
(3) floating point (float)
(4) and double-precision floating point (double) many of them also after extended data type such as long int and long double.
Data Types in C Language
|
Datatype
|
Value
|
Range
|
Size (bytes)
|
Format conversion specification
|
void
|
-
|
-
|
Zero
|
-
|
char (signed char)
|
Single character in single quote
|
-128 to 127
|
1
|
%c
|
unsigned char
|
Single character in single quote
|
0 to 255 (256)
|
1
|
%c
|
int (signed int)
|
Numeric value without fractional part
|
-32768 to 32767
|
2
|
%d, %i
|
unsigned int
|
Only +ve numeric value without fractional part
|
0 to 65535 (65536)
|
2
|
%u
|
long int (signed long int)
|
Large numeric value without fractional part
|
-2,147,483,648 to 2,147,483,648
|
4
|
%ld, %li
|
unsigned long int
|
Only large +ve numeric value without fractional part
|
0 to 4,294,967,295
|
4
|
%lu
|
Float
|
Real numbers with six-digit fractional part
|
-3.4E38 to 3.4E38
|
4
|
%f, %g, %e
|
Double
|
Real numbers with double precision
|
-1.7E308 to 1.7E308
|
8
|
%lf, %lg, %le
|
Long double
|
Very large floating point numbers
|
-3.4E4932 to 3.4E4932
|
10
|
%Lf, %Lg, %Le
|
Boolean (logical)
|
True(non-zero) False(zero)
|
-
|
2
|
-
|
char[] (String)
|
Character(s) in double quote
|
-
|
-
|
%s
|
User Defined Data Type
"C" supports a feather known as "type definition" that allows user to define identifier that would represent an existing data type. The user defined data type identifier can later be used to declare variables.
Example:
typedef type identifier;
enum identifier {value I ,value 2 .......};
enum day {Monday, Tuesday.........Sunday};
Derived Data Type
Derived data types are as arrays, functions, structures and pointers.
Empty Data Type
The data type void is used to specify an empty set of values. It can also use with function and pointers.