← Back to Exceptions
Question 736
Array Index Out Of Range
Array Index Out Of Range
An arrayarr = { 10, 20, 30 }is given. Read an index from input and printarr[index]. If the index is out of bounds, catch theIndexOutOfRangeExceptionand printError: index out of range. Use top-level statements withtry/catch. Input1prints: 20 Input5prints: Error: index out of range
Expected Output:
20= newline. The output ends with a newline — print one after the last line.
Hints2 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.