CJCoding With Joseph

Catch Any Exception

Read an integer n and print 100 / n. Instead of catching a specific type, catch the base Exception type so any failure is handled, and print exactly Something went wrong. Use top-level statements with try/catch.

Input 4 prints: 25
Input 0 prints: Something went wrong

Expected Output:

25
Topics:
Exceptions
๐Ÿ“ฅ Auto-Input:
4\n
This input is automatically fed to your program's stdin
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.