Data Types in C

Data Types in C



  • Datatypes represent the type of data stored in a variable.

data types in c

Primary datatypes:

  • These data types represent a single value. It means they store only one value.


  • The data types represent only one character, like N, n, 8,*? etc.
  • Char data type takes only 1 byte of memory.
char ch;        /* declare char type variable ch */
ch='A';         /* store A into ch */


  • This data type stores an integer number.
  • It takes 2 bytes of memory.
int num;       /* declare num variable as int type */
num=5000;      /* store 5000 into num */


  • This data type represents a number with a decimal point.
  • Float takes 2 bytes of memory.
float sal;         /* declare sal as float type */
sal='78965.80';    /* store 78965.80 into sal */


  • This data type represents a big float number.
  • It takes 8 bytes of memory.
double speed;      /* declare speed as double type variable */
speed=3.14e8;      /* store 3.1X10  power 8 into speed*/


  • It is a data type but it is not used with a variable to store data. So, it is called ’empty datatype’.
  • Generally, it is used before a function to specify that the function does not return any value.
void myfunction()
  • Here, myfunction() is the function name and void before it represents that this function will not return any result. Also, We can use void after the function name to specify that the function does not take any parameters.
int myfunction(void)
  • Here, myfunction() returns int type result.
  • myfunction(void) is not same as myfunction().
[su_table responsive=”yes” fixed=”yes”]
Data Types Range Bytes Format
signed char -128 to +127 1 %c
unsigned char 0 to 255 1 %c
short signed int -32768 to +32767 2 %d
short unsigned int 0 to 65535 2 %u
signed int -2147483648 to +2147483648 4 %d
unsigned int 0 to 4294967295 4 %u
long singed int -2147483648 to +2147483648 4 %lu
long unsigned int 0 to 4294967295 4 %lu
float -3.4e38 to +3.4e38 4 %f
double -1.7e308 to +1.7e308 8 %lf
long double -1.7e4932 to +1.7e4932 10 %lf

Click Here to Leave a Comment Below 0 comments

Leave a Reply: