1.

What is the difference between Type Casting and Automatic Type conversion? Also, give a suitable C++ code to illustrate both.

Answer»
Type CastingAutomatic Type conversion
It is an explicit process of conversion of a data from one type to another.It is an implicit process of conversion of a data from one type to another.
It is performed with the help of casting operator(). It is performed by compiler its own.
Example:
int A=1, B=2;
float C = (float)A/B;//Type Casting
cout<<C;
Output: 0.5
Example:
int N = 65;
char C = N; //Automatic type conversion
cout<<C;
Output: A


Discussion

No Comment Found

Related InterviewSolutions