Casting and Needs.

Q8. What is casting, when do we need it?

Ans. Casting is a form of conversion, which uses the cast operator to specify by a type name in parenthesis and is placed in front of the value to be converted. For example:

result = ( float ) total / count ;

They are helpful in situations where we temporarily need to treat a value as another type.

Leave a Reply

Your email address will not be published. Required fields are marked *