Skip to main content

Data Types in C Language

C Language Beginner level



Data Types in C Language : 

Data Type tells us the properties of a variable like how much Storage is allocated to a particlar variable and which kind of Data it stores .

There are various kind of Data Types available in C as -

Basic Data Types :

  • int
  • float
  • double
  • char 

Data Type Allocated Storage Range Note
 int  2 bytes or 4 bytes   -32,768 to 32,767
 float  4 bytes  1.2E-38 to 3.4E+38   It uses 6 Decimal Precision
 double  8 byte  2.3E-308 to 1.7E+308  It uses 15 Decimal Precision .
 char  1 byte  -128 to 127 or 0 to 255
 short  2 bytes   -32,768 to 32,767
 long   4 bytes   -2,147,483,648 to 2,147,483,647
 void   0 bytes   It does not contain any value and shows   Null value .

User Defined Data Types :
  • Array
  • Structure
  • Union 
Note : 

  • We can find out the Allocation Storage for any Data Type by using the sizeof( ) function in the C Code .  

How to use sizeof( ) function : 

#include <stdio.h>
void main() 
{
printf(" The Size of Integer Data Type is = %d " , sizeof( int )) ;
printf(" The Size of Character Data Type is = %c " , sizeof( char)) ;
printf(" The Size of Float Data Type is = %f " , sizeof( float)) ;
return 0 ;
}

Note :

  • Here printf( ) tells that , we are goint to print something on the screen using the code . 
  • The statement written inside the double quotes ( " " ) prints itself as same it is written . 
  •  Here %d , %f , %c are the Specifiers and tells that , we want to print a dynamic value here that is not written by users . 
  • Here sizeof(int) calculates the storage space of Integer data type . 
  • Here sizeof(float) calculates the storage space of Float data type .
  • Here sizeof(char) calculates the storage space of Character data type .
  • And print the calculated value at the place of Specifier in that particular statement output on the screen . 
Let's see the Array in the next Page .


                                                       << Back            >>Next

Comments