Data type

Previous Lesson                                                               Next Lesson



We can understand about data type in easy format
Data type specify with two different word "Data" and "Type"

" Data " specify the kind of value which is use in programme and " Type " is specify the kind of categories of value 

Data type is the specific contents of c language that is present some categories of value. 

C language use Various categories of value. each value is specify by there data type


" Decimal " type we know as an Integer datatype

Integer Data Type's :-

This type's of data type is used to specify the non floating point value.
Integer data type does not use floating point type of value at the assigning time and at the operation time.

C language use some categories of Integer datatypes

1. short ( 2 byte // 16 bit )
2. int     ( 2 byte // 16 bit )
3. long  ( 4 byte // 32 bit )

Short

         This is an integer datatype that is used to present non floating point value. it cant have any fractional value to get performance


short a,b,c ;
           a=-10 ;  // -10 store in variable a 
           b=20 ;  // 20 store in variable b
           c=a+b  ;  // calculate and 10 store in c

Memory space and Range

      Memory Space                  

       2 Byte (16 bit) 

Formula to find out range of bits
Short can hold both kind of value but it cant store more than -32768 to 32767

if user wants to store more than 32767 in positive case than we can use another categories of short called " unsigned short"  

Unsigned Short
         
This is an integer datatype that is used to present non floating point value and only positive value. it cant have any fractional and negative value to get performance


unsigned short a,b,c ;
           a=-10 ;  // -10 can't store in variable a  
           b=-20 ;  // -20 can't store in variable b
           c=a+b  ;  // can't calculate data does not exits 

unsigned short a,b,c;
          a=10
          b=20
          c=a+b;

Memory space and Range

      Memory Space                  

       2 Byte (16 bit) 

Formula to find out range of bits
-32768 System automatic remove sign bit from range 
and that range must added in with 32767

     32768
     32767
---------------
     65535          // Range of 2 Byte of unsigned short
---------------  

unsigned short can store 0 to 65,535 

short a=50650 ; // can be store.   


int data type

int type is a Same as short

         This is an integer datatype that is used to present non floating point value. it can't have any fractional value to get performance


int a,b,c ;
           a=10 ;  // 10 store in variable a 
           b=20 ;  // 20 store in variable b
           c=a+b  ;  // calculate and 30 store in c

Memory space and Range

      Memory Space                  

       2 Byte (16 bit) 

Formula to find out range of bits
Lets close look on Range of Int type
int can hold both kind of value but it cant store more than -32768 to 32767

if user wants to store more than 32767 in positive case than we can use another categories of int called " unsigned int"  

Unsigned Int
         
This is an integer datatype that is used to present non floating point value and only positive case of value. it can't have any fractional and negative value to get performance


unsigned int a;
           a=-10 ;  // -10 can't store in variable a 

Memory space and Range

      Memory Space                  

       2 Byte (16 bit) 

Formula to find out range of bits
-32768 System automatic remove sign bit from the range of int type
and that range must added in with  positive case 32767

     32768
     32767
---------------
     65535          // Range of 2 Byte of unsigned int
---------------  

unsigned int can store 0 to 65,535 

int a=50650 ;  // can be store.  


Long data type

         This is an integer datatype that is used to present non floating point value. it can't have any fractional value to get performance, this data type store more memory space and range than int and short type

long a ;
a=150000 ; // 150000 store in variable a

Memory space and range

  Memory Space                  

       4 Byte (32 bit) 

Formula to find out range of bits
Fractional Data Type's :-

This type's of data type is used to specify the floating point value.
Fractional data type present  floating point and decimal value in floating formate.

C language use some categories of Fractional datatypes

1. float        ( 4 byte // 32 bit )
2. double   ( 8 byte // 64 bit )

Float Data Type

         This is an fractional datatype. that is used to present floating point value to get performance, this data type store more memory space and range than int and short type

float a,b,c;
a=10;               // variable " a "  gets 10.00 
b=20.5;          // variable " b " gets 20.5
c=a+b;           // variable " c " gets 30.5

Memory space and range

  Memory Space                  

       4 Byte (32 bit) 

Formula to find out range of bits

Fractional Range

3.4 E - 38

float variable can have 6 digit after decimal

float a,b;
a=9785.482238 ;   // successfully store
b=7689.094528 ;  // successfully store

Double Data Type

         This is an fractional datatype. that is used to present floating point value to get performance, this data type store more memory space and range than float type

double a,b,c;    
a=10;               // variable " a "  gets 10.00 
b=20.5;          // variable " b " gets 20.5
c=a+b;           // variable " c " gets 30.5

Memory space and range

  Memory Space                  

       8 Byte (64 bit) 

Formula to find out range of bits
double variable can have 15 digit after decimal

double a,b;
a=91.9785482238 ;   // successfully store
b=91.7689094528 ;  // successfully store


Previous Lesson                                                                               Next Lesson


No comments:

Post a Comment