Data Types in C

Data types determine the following:
• Range of the data
• Type of the data stored
• Number of bytes it occupies in memory

C supports following data types:
• int – occupies 2 (16-bit compiler) or 4 bytes (32-bit compiler) of memory
• float – occupies 4 byes of memory
• double – occupies 8 bytes of memory
• char – occupies 1 byte of memory

int is used to define integer numbers. It occupies 2 bytes of memory (16-bit compiler)

float is used to define floating type numbers. It occupies 4 bytes of memory (16-bit compiler)

double is used to store big floating point numbers. It reserves 8 bytes of memory (16-bit compiler)

char is used to store characters. It occupies 1 byte of memory (16-bit compiler)

The modifiers define the amount of storage allocated to the variable.
int, float and double have the following four modifiers.
· short
· long
· signed
· unsigned
long is used to store long int
short is used to store short int
long double is used to store long double
Using signed int is redundant as int is signed by default.
Modifier long can be applied to double data type.

Following are the valid combinations:
long int or long (For 16 bit compiler: 4 byte)
short int or short (For 16 bit compiler: 2 byte)
signed int or int (For 16 bit compiler: 2 byte)
unsigned int (For 16 bit compiler: 2 byte)
short unsigned int
long unsigned int
char (Occupies 1 byte of memory)
signed char or char (Range: -128 to +127, Occupies 1 byte of memory)
unsigned char (Range: 0 to 255, Occupies 1 byte of memory)
long double (Occupies 10 bytes of memory)

Following rule applies:
short int <= int <= long int float <= double <=long double Summary:
Following table is applicable for 16-bit compiler.

Data Type Bytes
short int 2
sshort unsigned int 2
sshort signed int 2
ssigned int 2
sunsigned int 2
slong int 4
slong unsigned int 4
slong signed int 4
sfloat 4
sdouble 8
slong double 10
schar 1
ssigned char 1
sunsigned char 1

You may also like...

27 Responses

  1. Anonymous says:

    absolutely fantasti

  2. Anonymous says:

    Yes this is definitly the best webpage that I have ever viewed …ever !!!!!!!!!1

  3. Anonymous says:

    great

  4. Anonymous says:

    good work

  5. matneo says:

    you should provide size for 32-bit compilers as 16-bits are now obsolete. Though nice article.

  6. Anonymous says:

    what is diff between signed n unsigned??

  7. Anonymous says:

    sign refers to the positive or negative sign before integer
    no sign or unsigned means non negative integers
    now signed means it can take negative integers also

  8. vino says:

    if some ask me , write data types in c.
    what should i write? 14 data types or int,float,double,char only?

    ans me frds…

  9. Anonymous says:

    Hi Its all good but there is a small correction to be made… The character is declared as alp =

  10. Anonymous says:

    I thought it was A not ‘A’

  11. Anonymous says:

    i think for short int,short unsigned int and short signed int, its 1 byte on 16 bit compiler(As per ANSI C, Balagurusamy E,5e,Pg. 33)
    If its wrong, let me know pls…

  12. Anonymous says:

    no its correct ………short int,short unsigned int and short signed int its 2 bytes……….

  13. Vard says:

    So why here this is

  14. C V KASHYAP says:

    good info……….

  15. precise…very helpful for beginners..

  16. Anonymous says:

    more c samples please…:)

  17. Anonymous says:

    good webpage

  18. Hantenks says:

    What’s the difference between signed and unsigned (in modifiers)?

  19. Anonymous says:

    This site is very helpful in learnng c and i like it
    and have a request that please… provide some deep knowladge of these content inspite of just an overview…

  20. Anonymous says:

    GOOD………..

  21. venkat pott says:

    great collection

    venkatt

  22. akhil says:

    well,what is signed char and unsigned char

  23. patel dhruvit says:

    why the turbo c have int of 2byte and
    gcc have int of 4byte

    • Aditya Salunkhe says:

      It depends on architecture of the processor, if your gcc compiler runs on i386 instruction set ie 32 bit instruction set it will be 4 bytes, while on x86 machines it will be 8 bytes. As per the turbo c case im not sure if u are using dos-box emulator and the turboc compiler default size prefrence its diffrent for every compiler and you can change it too 🙂

Leave a Reply

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