What are the type of casting shown by the following example?
(1) double x=15.2;
(2)int y=(int)x;
Answers
Answered by
73
Answer:
Explicit casting
Explanation:
Because a double type variable is converted to int type.
Hence there is loss of fractional part.
Hope it helps
Answered by
0
Typecasting is changing one variable's type into another different type.
- Explicit typecasting, and implicit type casting are the two ways to change the data types.
- here, the given expressions "double x= 15.2; & int y =(int)x; " are explicit typecasting.
- In explicit typecasting one variable is done by the user forcefully.
- Another name for Explicit typecasting is Typecasting.
- Here, double x =15.2; int y =(int)x;. Then when you take the output of 'y ' it will print 15.
Similar questions