Bounds-Checked at()
easyQuestion 531An array<int, 4> named a holds {1, 2, 3, 4} and an int index is set to 10. A try/catch block is already written: the catch prints the error message. Inside the try block, first read a.at(index) into an int variable named value, then print the word Value:, a space and value followed by a newline.
Expected output
Index 10 is out of range= newline. The output ends with a newline, so print one after the last line.
Hints2 available
Sign in to use hintsTopics
STL Containersstd::array
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.