Type Casting :-
Type casting is the way to convert the data from one type to other type. Exp:- Converting the short int to long int vice versa.
Type of Type Casting:-
- Implicit Type Casting
- Explicit Type Casting
Implicit Type Casting :-
When Type Casting is performed automatically by the compiler, without programmers intervention, such type of conversion is know as Implicit Type Casting.
Exp:- int a = 10, r;
short int b = 20;
r = a + b ;
// in 32bit OS// int size is 4 byte , short int size 2 byte.
// r and a size is 4 byte and b size is 2 byte, but when the expression is going to solve the
Explicit Type Casting :-
When Type Casting is performed forcefully by programmers, that is known as Explicit Type Casting .
Exp:- Take same example for easy to understand
short int a = 10, r;
Explicit Type Casting :-
When Type Casting is performed forcefully by programmers, that is known as Explicit Type Casting .
Exp:- Take same example for easy to understand
short int a = 10, r;
int b = 20;
r = a + ( short int )b ;