Type Conversion

Data Types

Type conversion

Type conversion is the process of converting one predefined data type into another data type.



Explicet type conversion is also known as type casting.

Ex
int a;
double b=2.55;
a=b; //implicit type conversion.
cout << a << endl; // this will print 2
a = int (b); //explicit type conversion
cout << a << endl; // this will print 2

Implicit Type Conversion



Type Casting(Explicit)

In c++ explicit type conversion is called type casting.
Syntax
type-name(expression) //c++ notation Ex
Average = sum/(float)i; //c notation
Average = cum/float(i); // c++ notation