Here's your approach for safe division:
Write a divide function that checks if denominator is zero.
If zero, throw runtime_error with a descriptive message.
Otherwise, perform the division and return the result normally.
In main, wrap the divide call in a try block.
Add a catch block for runtime_error that prints the error message.
Add cleanup or continuation code after the try-catch. The program recovers instead of crashing.