Data types in C

Data types in C Programming Language are used to declare the memory location that determines the characteristics of the data.

  • There is an associated data type with each variable.
  • Different data types require different amount of memory.

There are 5 common data types in C:

  1. char: IN C it is the most basic data type and It stores a single character and requires a single byte of memory in almost all compilers.
  2. int: It is used to store an integer.
  3. float: It is used to store decimal numbers with single precision.
  4. double: It is used to store decimal numbers with double precision.
  5. void – valueless special purpose type data type.

Different data types also have different ranges

Data Type             Memory (bytes)          Range                      Format Specifier
short int                   2          -32,768 to 32,767                       %hd
unsigned short int          2           0 to 65,535                            %hu
unsigned int                4           0 to 4,294,967,295                     %u
int                         4          -2,147,483,648 to 2,147,483,647         %d
long int                    4          -2,147,483,648 to 2,147,483,647         %ld
unsigned long int           4           0 to 4,294,967,295                     %lu
long long int               8          -(2^63) to (2^63)-1                     %lld
unsigned long long int      8           0 to 18,446,744,073,709,551,615        %llu
signed char                 1          -128 to 127                             %c 
unsigned char               1           0 to 255                               %c
float                       4                                                  %f
double                      8                                                  %lf
long double                 12                                                 %Lf


Leave a Reply

Your email address will not be published. Required fields are marked *