02 b] What is typecasting? Mention its use with a suitable example
Answer:-
“Typecasting, or type conversion, is a method of changing an entity from one data type to another.”
It is used in computer programming to ensure variables are correctly processed by a function.
Example:-
int float_to_int(float a) // example: a = 2.75
{
int b = (int)a; // typecast float to int
return b; // returns 2
}
or