Computer Science, asked by Vaswata860, 1 year ago

Difference between implicit and explicit type conversion

Answers

Answered by tannutiwari
6
The basic difference between implicit and explicit implict is taken care of by the compiler, itself, while explicit is done by the programmer in the above statement, the conversion of data from into it double is done implicitly in other words programmer don't need to specify any type operators
Answered by anjali17103
2

Consider a variable float "num1" holding value "25.5", second variable int "num2" holding value "10".

ie:

float num1=25.5;

Int num2=10;


If we have to add these numbers, we have two ways:

1. Int sum = num1+num2;

Here, "sum" is a integer variable and so it won't hold decimal value.

The final value would turn out to be 35 here. ie. sum=35, neglecting 0.5.

This was implicit conversion.



On other hand,

2. float sum = num1+num2

ie. sum = 25.5+10;

Here, the value of "sum" is 35.5, because here datatype of "sum" is float.

Hence, sum=35.5, not neglecting 0.5.

This is explicit conversion.

Similar questions