SAMIR UDDIN

Hello guys welcome to my web blog ,my very special blog gives you latest technical knowledges and I want to proviod you quality and short posts .If you need any type of posts please tell me in comment section,If anybody have some questions related to my posts please tell me at https://www.samirmd.blogspot.com https://www.youtube.com/channel/UC4k3h0R2H8HVSQqAbuYY27Q https://www.facebook.com/mdsamir.shaikh.948

Latest Tweets

LightBlog
Responsive Ads Here

Monday, September 25, 2017

Type Conversion

Type conversion is done when the expression has variables of different data types
§Type conversion is used to convert a type of a variable into another data types.
§There are two types of Type conversion in Computer programming..
§Implicit is a type conversion in which is done automatically during program execution  according
to hierarchy of data types as shown in the figure.
     Long double
           
       Double
           
        Float
          
Unsigned Long int
           
     Long int
         
Unsigned int
     ⬇
     Char
§Examples              float f;                                 float salary=15000.0
 float x;                    int I;                                             int sal
Int y=3;                    f=I;                                               sal=salar y
  

Typecasting

§It is a type of explicit /forced  conversion in which value of
higher data type is converted into the value of lower data type
lower data types.
§This  typecasting is under the programmer’s control and not
under the compiler’s control.
Example
#include<stdio.h>
int main() 
{ 
  float f,int i;
  printf(\nEnter the floating point number:  );
  scanf(%f,&f);
  i=(int)f;
  printf(\n %d,f, i);
  return 0;
}
Output    Enter the floating point number:3.76
               The integer variant of %f is =3
                             
Long double