C Programming language

Data Type in C

In this section we are going to provide The following Data Type in C.

Previous Home Next

Integer Type

Integer variable is whole number variable n the range of that variable is machine dependent. A programmer should always take care f the range of that variable n also take care of the storage capacity. Integer can be signed and unsigned.

There are three classes of integer in c are Short int, integer, long int. the difference between these classes only of its range.

TYPESIZE (Bits) Range
Int or Signed int16 -32768 to 32767
Unsigned int16 0 to 65535
Short int or Signed short int8 -128 to 127
Unsigned short int8 0 to 255
Long int or signed long int 32 -2147483648 to 2147483647
Unsigned long int 32 0 to 4294967295

Example


int main( )
{
int a=
10 ; // a contain integer type value.
return a;
}

Data typeKeyword Equivalent
Signed Integer signed int (or) int
Signed Short Integer signed short int (or) short int (or) short
Signed Long Integersigned long int (or) long int (or) long
Unsigned Integerunsigned int (or) unsigned
Unsigned Short Integerunsigned short int (or) unsigned short
Unsigned Long Integer unsigned long int (or) unsigned long

Float Type

Floating point variable represent a real number with 6 digits precision. Float keyword use for floating point number. The accuracy of floating point number is insufficient so use double .double is same as floating point number but range of precision is longer then the float.

To extend the precision further we can use long double which consumes 80 bits of memory space.

TYPESIZE (Bits) Range
Float32 3.4 e-38 to 3.4 e+38
Double64 1.7e-308 to 1.7e+308
Long Double80 3.4 e-4932 to 3.4 e+4932

Data typeKeyword Equivalent
Floating Point float
Double Precision Floating Point double
Extended Double Precision Floating Pointlong double

Example


float main( )
{
float a=10.344 ; // a contain float type value.
return a;
}

char Type

The capability of char is holding one character in the local character set. Characters are usually stored in 8 bits of internal storage or can say that one byte. In the char the qualifier signed or unsigned can be explicit applied. While unsigned characters have values between 0 and 255, signed characters have values from 128 to 127.

The character set in C Language can be grouped into the following categories.

  1. Letters
  2. Digits
  3. Special Characters
  4. White Spaces
TYPESIZE (Bits) Range
Character 8 -128 to 127
Unsigned Character 8 0 to 255
Data typeKeyword Equivalent
Character char
Unsigned Characterunsigned char
Previous Home Next