TYPES OF VARIABLE IN C or NUMERIC DATA TYPES IN C PROGRAMMING

Variable Type Keyword Bytes Required Range
Character char 1 -128 to 127
Integer int 2 -32768 to 32767
Short integer short 2 -32768 to 32767
Long integer long 4 -2,147,483,648 to 2,147,438,647
Unsigned character unsigned char 1 0 to 255
Unsigned integer unsigned int 2 0 to 65535
Unsigned short integer unsigned short 2 0 to 65535
Unsigned long integer unsigned long 4 0 to 4,294,967,295
Single-precision float 4 1.2E-38 to
floating-point 3.4E38(1*)
Double-precision double 8 2.2E-308 to
floating-point 1.8E308(2*)
(1*)Approximate range; precision = 7 digits.
(2*)Approximate range; precision = 19 digits.

PROGRAM TO PRINT THE SIZES OF DATA TYPES


#include <stdio.h>

main()
 {
 printf( "\nA char is %d bytes", sizeof( char ));
 printf( "\nAn int is %d bytes", sizeof( int ));
 printf( "\nA short is %d bytes", sizeof( short ));
 printf( "\nA long is %d bytes", sizeof( long ));
 printf( "\nAn unsigned char is %d bytes", sizeof( unsigned char ));
 printf( "\nAn unsigned int is %d bytes", sizeof( unsigned int ));
 printf( "\nAn unsigned short is %d bytes", sizeof( unsigned short ));
 printf( "\nAn unsigned long is %d bytes", sizeof( unsigned long ));
 printf( "\nA float is %d bytes", sizeof( float ));
 printf( "\nA double is %d bytes\n", sizeof( double ));

 return 0;
 }

OUTPUT:
A char is 1 bytes
An int is 2 bytes
A short is 2 bytes
A long is 4 bytes
An unsigned char is 1 bytes
An unsigned int is 2 bytes
An unsigned short is 2 bytes
An unsigned long is 4 bytes
A float is 4 bytes
A double is 8 bytes

Advertisements
This entry was posted in C. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s