**Implicit type Conversion in C | Automatic type conversion in C**

Implicit conversion means automatic conversion. It is the way in which the output of an arithmetic expression is converted automatically into a particular data type.

The basic rule of implicit conversion is that the output of an expression will be of that data type which has the highest number of bytes and range.

For example if one operand is of int type and other of float type, the output will be of float type as float type has larger size and range of values compared to int data type.

There are some rules of implicit conversion which are as follows:

Data type of first operand | Data type of second operand | Data type of Output |

short | short | short |

short | int | int |

short | long | long |

short | float | float |

short | double | double |

short | long double | long double |

short | char | short |

int | int | int |

int | long | long |

int | float | float |

int | double | double |

int | long double | long double |

int | char | int |

long | long | long |

long | float | float |

long | double | double |

long | long double | long double |

long | char | long |

float | float | float |

float | double | double |

float | long double | long double |

float | char | float |

double | double | double |

double | long double | long double |

double | char | double |

long double | long double | long double |

long double | char | long double |

char | char | char |

Program to demonstrate implicit conversion. |

#include<stdio.h>int main(){int a,b,c;float d, e;a=10;b=3;c=a/b; /*Line 10*/printf(“\nc=%d”,c);d=a/b; /*Line 12*/printf(“\nd=%f”,d);e=a/d; /*Line 14*/printf(“\ne=%f”,e);c=a/d; /*Line 16*/printf(“\nc=%d”,c);return(0);} |

Output: |

c=3d=3.000000e=3.333333c=3 |

Description |

** In line 10 of above program, a and b are of int type so result of a/b will be of int type i.e. 3 which has been assigned to variable c which is also of int type. So c will contain 3. In line 12, a and b are of int type so result of a/b will be of int type i.e. 3. which has been assigned to variable d which is also of float type. So d will contain 3.000000. In line 14, a is of int type and d is of float type so result of a/b will be of float type i.e. 3.333333 which has been assigned to variable e which is also of float type. So e will contain 3.333333. In line 16, a is of int type and d is of float type so result of a/b will be of float type i.e. 3.333333 which has been assigned to variable c which is of int type. So c will contain 3 as int variable c can’t contain digits after decimal point. |