Give the difference between the Type Casting and automatic Type Conversion. Also, give a suitable C++ code to illustrate both.
Type Casting | Automatic Type Conversion |
Type Casting is used to convert the value of one type to another type. | Automatic Type Conversion is the type conversion done by the compiler wherever required. |
For example, float x = (float)3/2; //1.5 will be assigned as result, because 3 is converted into 3.0 |
For example, float x = 3/2; // here 1.0 will be assigned as result, because 1 is automatically converted in 1.0 |