C Data Types

C data types indicates what type of data to be stored and what is the range of data that we can store or carried out on those particulars.

Data type can be classified as follows:-

  • Primitive data type (int, char, float, double)
  • Derived data type (function, pointer, files, array)
  • User defined data type (structure, union etc)

C Data TypesClick here to purchase home decoratives.

Integer and char having two types of register i.e. signed and unsigned.

Unsigned : In unsigned register number should always be positive.
Signed : in signed register number may be positive or negative.

If the sign qualifier is not mentioned then by default signed register is assumed.
In case of char if the sign qualifier is not mentioned then the type of char is signed or unsigned depends upon machine. The size of different data type along with their format specifier are mentioned below:

Data type Size(in bytes) Range Format specifier
signed  char 1 -128 t0 127 %c
unsigned  char 1 0 t0 255 %c
short int 2 -32768 to 32767 %hi
int or signed int 2(16 –bit compiler) -32768 to 32767 %i or %d
  4(32/64 –bit compiler) -2147483648 to 2147483647 %i or %d
unsigned int 2(16 –bit compiler) 0 to 65535 %i or %d
  4(32/64 –bit compiler) 0 to 4294967295 %i or %d
long int or
signed long int
4 -2147483648 to 2147483647 %li or %ld
unsigned long 4 0 to 4294967295 %li or %ld
Float 4 1.2E-38 to 3.4E+38 %f or %e or %g
double 8 2.3E-308 to 1.7E+308 %lf or %le
long double 10(16-bit compiler) 3.4E-4932 to 1.1E+4932 %Lf or %Le or %Lg
  12(32-bit compiler) 3.4E-4932 to 1.1E+4932 %Lf or %Le or %Lg

Note : depending upon compiler, size of data type will vary.
There are various tutorials available which provides the details about C Data Types.
We can also find the size of data types using following code:

Why we use data types in programming language, like C Data Types?

We have a concepts of C Data Types but have you think, Why we uses data types?. If such question are coming in your mind then I can say you have learnt something from this tutorials. Now, data types are used to identify and classify difference types of data. Which helps to perform different types of operation based on the data.
What will be the results of the following expression
Computer doesn’t know about the above expression. We have to teach each part to the computer to perform the operation. Which is done by the program with the help of data types. So Data types are very simple but useful concept for the programming language.

Click here to download pdf of above tutorial.  

Leave a Reply