C language – Data Types in C Programming language

Data types in c language

The data type is the data that will be accessed within the program. C language supports different data types, each data type may have predefined memory requirement and storage representation.

C programming language supports the following 4 classes of data types

PrimaryUser definedDerivedEmpty
char, int, float, doubletypedefarrays, pointer, structures, unionvoid

The bytes occupied by each of the primary data types are

Datatypes Description Memory bytes Format
int Integer Quantity 2 bytes %d or %i
char Single Character 1 byte %c
float Floating pointing no’s 4 bytes %f or %g
double Double precision floating pointing no’s 8 bytes %ld

[Note: All C language compiler supports the five fundamental data types called int, char, float, double and void.]

The primary data types are divided into the following.

Integer Type
intunsigned int
short intinsigned short int
long intunsigned long int
Data type in c programming

Integer type

In C language Integers are the numbers with the supported range, usually, the integers occupy one word of storage typically 16 to 32 bits. The size of the integer depends upon the system.

Eg. If you use a 16-bit word length, the size can be limited from -32768 to +32767.

To get the exact size of a type or a variable on a particular platform, you can use the sizeof driver. The expression sizeof ( type) yields the storage size of the object or type in bytes. Following is an example to get the size of int type on any machine


Storage size for int : 4

Character Types in C language

Character is generally stored in 8 bits of the internal storage of the computer and a single character can be defined as a char data type.

TypeStorage sizeValue Range
char1 byte-128 to +127
unsigned char1 byte0 to 255

Float Type

In C language floating-point numbers are generally stored in 32 bits with 6 digits of precision. These numbers are defined by using the keywords float and double, whereas the double data type uses 64 bits with 14 digits of precision.

The following table gives you important points about standard floating-point types with storage sizes and value ranges and their precision:

TypeStorage sizeRangePrecisionControl String
float4 bytes3.4E-38 to 3.4E+386 decimal places%f
double8 bytes1.7E-308 to 1.7E+30815 decimal places%lf
long double10 bytes3.4E-4932 to 1.1E+493219 decimal places%lf

The header file float.h defines macros that allow you to use these values and different details about the binary representation of real numbers in your programs.

The following example will print storage space taken by a float type and its range values:


Storage size for float : 4 
Minimum float positive value: 1.175494E-38
 Maximum float positive value: 3.402823E+38
 Precision value: 6

Void Type:

The void is a null data type in the C  programming language. This is generally specified with the function which has no arguments.

Type Qualifiers in C language

If you use a 16-bit word length, the size of the data type is limited to the specific range.

So in order to provide some control over the range of numbers and storage space of the type, some basic data types, basic data types can be argumented by using the data type qualifiers, they are,

short, long, signed, unsigned

The declaration of long and unsigned integers permits us to increase the range of values. The precedence of a signed declaration for an integer is essential as the default declaration assumes signed numbers.

Typesize (bytes)RangeControl String
char or signed char1-128 to 127%c
unsigned char10 to 255%c
int or signed int2-32,768 to 32,767%d or %i
unsigned int20 to 65,535%u
short int or signed short int1-128 ro 127%d to %i
unsigned short int10 to 255%d to %i
long int or signed long int4-2,147,483,648 to 2,147,483,647%ld
unsigned long int40 to 4,294,967,295%lu