Monday, January 21, 2008

Data types: A basic in C

Data Types:
Data type is used to specify what kind of data we are going to use to the computer.
There are three data types available in 'C'. They are
-Integer
-Real
-Float
Integer:
This is used to store integer without decimal point.
There are four types of integer they are
-short(1 bytes)
-int(2 bytes)
-long(4 bytes)
-long double(8 bytes)
Integer has two bytes of size to store data. Int can store -32768 to 32767. Let us see how this number is got.
2 byte has 16 bits.
1 bit for indicating sign 0-Positive and 1- negative.
Remaining 15 bits is used to store numbers. 2 power 15 is 32768. We can store -32768 to 32767.
Same way for long int it has size 4 bytes.
In unsigned int and long int there is no sign bit and all are positive numbers.

Real:
Real numbers has decimal point. There are two types of real number and they are
Float(4 bytes)
Double(8 bytes)
These are expressed with mantissa and exponent. The component before decimal point is mantissa and after the decimal point is exponent.

Character:
Char is one byte and it is used to store 128 characters with their ASCII value.


No comments: