data types in c language

Data type in "C" language.

    The capacity of storing values in a variable is called data type. "C" language has became popular due to  following data types.

1.Numeric data type
2.Character data type
3.Logical data type

1.Numeric data type
    The data type which holds only numerical values from 0 to 9 is called numeric data type. It is further classified in to following types.

1. Integer (int)
    An integer data type holds only digits from 0 to 9. It does not allow any symbol without 0 to 9. It occupies 2 byte of memory. The range of that data type is  -32,768 to +32,767.
Example:-
int a=1541;
int a=63,b=545;

2.Unsigned short Integer (unsigned short int )
    An integer data type holds only digits from 0 to 9. It does not allow any symbol without 0 to 9. It occupies 2 byte of memory. The range of that data type is  0 to 65,535.
Example:-
int a=45625;
int a=25862,b=52415;

3. Long Integer (long int)
    An integer data type holds only digits from 0 to 9. It does not allow any symbol without 0 to 9. It occupies 4 byte of memory. The range of that data type is  -2147483648 to 2147483647.
Example:-
int a=52154452;
int a=63524154,b=85481458;

4.Float / real (float)
    It is same as integer data type but having a decimal point(.). It allows a symbol with 0 to 9 called decimal i.e(.). It occupies 4 byte of memory. 
Example:-
float a=25.36;
float a=635.25,b=854.520;

5.Double (double)
    It is same as integer but having a decimal point(.). It allows a symbol with 0 to 9 called decimal i.e(.). It occupies 8 byte of memory. 
Example:-
double a=5252.3625;
double a=845.252,b=5454.520;

5.Long Double (double)
    It is same as integer but having a decimal point(.). It allow a symbol with 0 to 9 called decimal i.e(.). It occupies 16 byte of memory. 
Example:-
long double a=5258542.35845;
long double a=84547.252,b=55454.5520;

2.Character data type
    The data type which holds alphabets from a to z  is called character data type. It is further classified in to following types.

1. Character (char)
    It holds character's from a to z and enclosed within a pair of single quote(') &('). It occupies 1 byte of memory. The range of that data type is -128 to +127.
Example:-
char a='x';

2. String.
    The collection of characters which are enclosed within a pair of double quote and ended with a special character i.e null '\0' character is called string.
Example:-
char a[2]="hi";

2.Logical data type
    The data type which is based on logical data true or false is called logical data types.
1-true
0-false



Name of the

Data type

Memory space in (byte)

Range

Char

1

-128 to +127

Unsigned char

2

0 to 255

Signed char

1

-128 to +127

Int

2

-32768 to +32767`

Unsigned int

2

0 to +65535

Signed int

2

-31768 to +32767

Long int

4

-2147483648 to +2147483647

Float

4

3.4E-38 to 3.4E+38

Double

8

1.7E.308 to 1.7E+308

Long double

16

3.4E-4932 to 1.1E+4932

 










      



No comments: