The data type supported in a language dictates the type of values which can be processed by the language.
C supports several different types of data, each of which may be represented differently within the computers memory.
Data types are means to identify the type of data and associated operations for handling it. Every variable in C has a data types.
Primitive data type is also known by different names such as Basic (or) simple or built in data types in C. Data types basically specify how we enter data into our programs and what type of data we enter.
Primitive data type can be augmented by using the data type qualifiers short, long, signed and unsigned.
The memory requirements for each data type may vary from one C compiler to another.
Given bellow are the primitive data types in c
Integers are used to store whole numbers.
In C programming, 4 Bytes memory is allocated for Integer datatype. Size and range of Integer type on 16-bit machine is given below:
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 |
Char is a data type which is used to represent individual characters. The char type will generally require one byte of memory. A char data type may have the identifiers signed and unsigned.
Character types are used to store characters value. Character data type allows a variable to store only one character.
Size and range of Integer type on 16-bit machine are given below:
Type | Size(bytes) | Range |
---|---|---|
char or signed char | 1 | -128 to 127 |
unsigned char | 1 | 0 to 255 |
Floating point data type store numerical values with a fractional portion.
There are two types of floating data types named float and double. These may also have the qualifier long.
Long float may be equivalent to double and long double may be equivalent to double, or it may refer to a separate, "extralarge" double-precision data type requiring more than 8 bytes of memory.
Floating point numbers are essantially signed and it is used to store a real numbers.
Size and range of Integer type on 16-bit machine are given below:
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 |
Double data type is also same as float data type which allows up-to 10 digits after decimal. The range for double datatype is from 1E–37 to 1E+37.
Double data types is also used for real numbers.
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 |
This is usually used to specify the type of functions which returns nothing. We will get acquainted to this datatype as we start learning more advanced topics in C language, like functions, pointers etc.
Void is an empty data type that has no value. This can be used in functions and pointers.