CJCoding With Joseph
15free / daySign inCreate account

Bounds-Checked at()

An 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 — print one after the last line.

Hints2 available
Topics:
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.