← Back to Exceptions
Question 761
Catch Any Exception
Catch Any Exception
Read an integernand print100 / n. Instead of catching a specific type, catch the baseExceptiontype so any failure is handled, and print exactlySomething went wrong. Use top-level statements withtry/catch. Input4prints: 25 Input0prints: Something went wrong
Expected Output:
25= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
Exceptions
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.