Type conversion (also called type casting) allows you to convert a value from one data type to another.
Implicit conversion happens automatically when the compiler can safely convert one type to another:
int number = 5;
double decimal = number; // Implicit conversion: int → double
// decimal now contains 5.0
Explicit conversion (casting) is when you manually tell the compiler to convert a type:
double pi = 3.14159;
int rounded = (int)pi; // Explicit conversion: double → int
// rounded now contains 3 (truncated)
Note: Be careful with explicit conversions as they can result in data loss!
Create a double variable named temperature with value 98.6, then convert it to an int and store the result in a variable called tempInt.
Click "Check Answer" to run your code.