Data type specifies the set of values and the type of data that can be stored in a variable. Each data type requires different amounts of memory and has some specific operations which can be performed over it.
In the c programming language, data types are classified as follows
The following are the primary data types in c programming language
This data type is used to store characters.These characters are internally stored as integers known as ASCII code.Each character has an equivalent ASCII value eg: ´A´ has ASCII value 65
Data Type | Memory Size | Range | Format Specifier |
signed char | 1 | -128 to 127 | %c |
unsigned char | 1 | 0 to 255 | %c |
The integer data type is a set of whole numbers. Every integer value does not have the decimal value. We use the keyword "int" to represent integer data type in c. We use the keyword int to declare the variables and to specify the return type of a function. The integer data type is used with different type modifiers like short, long, signed and unsigned. The following table provides complete details about the integer data type.
Data Type | Memory Size | Range | Format Specifier |
short int | 1 to 2 | -32,768 to 32,767 | %hd |
int | 2 to 4 | -2,147,483,648 to 2,147,483,647 | %d |
long int | 4 | -2,147,483,648 to 2,147,483,647 | %ld |
Note:The size of int in c Language depends on both processors and compilers. For example, in 16-bit machines, sizeof (int) was 2 bytes. 32-bit machines have 4 bytes
Floating-point data types are a set of numbers with the decimal value. Every floating-point value must contain the decimal value.The float value contains 6 decimal places eg:26.300000
Data Type | Memory Size | Range | Format Specifier |
float | 4 | -2,147,483,648 to 2,147,483,647 | %f |
Note: long float is same as double.
Double is also a datatype which is used to represent the floating point numbers. The double value contains 15 decimal places.
Data Type | Memory Size | Range | Format Specifier |
double | 8 | 3E-308 to 1.7E+308 | %lf |
long double | 10 | 3.4E-4932 to 1.1E+4932 | %Lf |