Data-types in C Programming language
Data-types in c refer to an extensive system used for declaring variables or functions of different types. The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted.
There are the following data types in C language.
Types | Data Types |
Basic Data Type | int, char, float, double |
Derived Data Type | array, pointer, structure, union |
Enumeration Data Type | enum |
Void Data Type | void |
- Primary data types
• char: The most basic data type in C. It stores a single character and requires a single byte of memory in almost all compilers.
• Int: As the name suggests, an int variable is used to store an integer.
• Float: It is used to store decimal numbers (numbers with floating point value) with single precision.
• Double: It is used to store decimal numbers (numbers with floating point value) with double precision.
- Derived data types
Derived data types are nothing but primary data types but a little twisted or grouped together like array, structure, union and pointer. These are discussed in details later.
Type | Size (bytes) | Format Specifier |
int | at least 2, usually 4 | %d, %i |
char | 1 | %c |
float | 4 | %f |
double | 8 | %lf |
short int | 2 usually | %hd |
long int | at least 4, usually 8 | %ld, %li |
long long int | at least 8 | %lld, %lli |
signed char | 1 | %c |
long double | at least 10, usually 12 or 16 | %Lf |