Data Type in C
In this section we are going to provide The following Data Type in C.
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.
TYPE | SIZE (Bits) |
Range |
Int or Signed int | 16 |
-32768 to 32767 |
Unsigned int | 16 |
0 to 65535 |
Short int or Signed short int | 8 |
-128 to 127 |
Unsigned short int | 8 |
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 type | Keyword Equivalent |
Signed Integer | signed int (or) int |
Signed Short Integer | signed short int (or) short int (or) short |
Signed Long Integer | signed long int (or) long int (or) long |
Unsigned Integer | unsigned int (or) unsigned |
Unsigned Short Integer | unsigned 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.
TYPE | SIZE (Bits) |
Range |
Float | 32 |
3.4 e-38 to 3.4 e+38 |
Double | 64 |
1.7e-308 to 1.7e+308 |
Long Double | 80 |
3.4 e-4932 to 3.4 e+4932 |
Data type | Keyword Equivalent |
Floating Point | float |
Double Precision Floating Point | double |
Extended Double Precision Floating Point | long 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.
-
Letters
-
Digits
-
Special Characters
-
White Spaces
TYPE | SIZE (Bits) |
Range |
Character | 8 |
-128 to 127 |
Unsigned Character | 8 |
0 to 255 |
Data type | Keyword Equivalent |
Character | char |
Unsigned Character | unsigned char |