DATA TYPES IN C LANGUAGE
Datatypes are names or labels which are used to define the kind of data being stored or manipulated. In any
programming language, data type specifies the range of values that a variable can hold and how this information
is stored in the memory.
Data
Types in C
User
Primary Derived Void
Defined
• Primary or Fundamental Data Types: These are basic built-in data types of C programming language.
There are four fundamental data types in C programming. These are int, char, float and double.
• Derived Data Types: Those data types which are derived from the fundamental data types are
called derived data types. Function, arrays, strings and pointers are derived data types in C programming
language.
• User Defined Data Types: Those data types which are defined by the user as per his/her will are
called user-defined data types. Examples of such data types are structure, union and enumeration.
• Void Data Type: Void is an empty data type that has no value. We use void data type in functions when
we don’t want to return any value to the calling function. It is also used in pointers. Note that, you
cannot create variables of void type.
Data type modifiers in C:
In C language Data Type Modifiers are keywords used to change the default properties of int and char data
types. Modifiers are prefixed with basic data types to modify (either increase or decrease) the amount of storage
space allocated to a variable.
Data type modifiers are classified into following types.
• short - It limits user to store small integer values from -32768 to 32767. It can be used only on int data
type.
• long - It allows user to store large numbers as compared to short. Syntax “long long” is used instead of
“long int”.
• signed - It is default modifier of int and char data type if no modifier is specified. It says that user can
store both negative and positive values from the permissible range.
• Unsigned – It is used when user intends to store only positive values in the given data type (int and char).
Summary of the data types:
Data Memory Size Format
Range
Type in Bytes Specifier
short 2 −32,768 to 32,767 %hd
signed
2 −32,768 to 32,767 %hd
short
unsigned
2 0 to 65,535 %hu
short
int 2 −32,768 to 32,767 %d, %i
signed int 2 −32,768 to 32,767 %d,%i
unsigned
2 0 to 65,535 %u
int
short int 2 −32,768 to 32,767 %hd
signed
2 −32,768 to 32,767 %hd
short int
int
unsigned
2 0 to 65,535 %hu
short int
long 4 -2,147,483,648 to 2,147,483,647 %ld
long int 4 -2,147,483,648 to 2,147,483,647 %ld, %li
signed
4 -2,147,483,648 to 2,147,483,647 %ld, %li
long int
unsigned
4 0 to 4,294,967,295 %lu
long int
long long −9,223,372,036,854,775,807, +9,223,372,0
8 %lld, %lli
int 36,854,775,807
unsigned
long long 8 0 to 18,446,744,073,709,551,615 %llu
int
char 1 −128 to 127 %c
signed
char 1 −128 to 127 %c
char
unsigned
1 0 to 255 %c
char
float float 4 -3.4E38 to +3.4E38 %f
double 8 -1.7E308 to +1.7E308 %lf
double long
10 -3.4E4932 to +1.1E4932 %Lf
double
Note: The sizes and ranges of int, short and long are compiler dependent. Sizes in this table are for 16-bit
compiler.