Create an array of size 5. Try to store 100 to the index 21 of the array. It should give you a
runtime error. Note the first line of the error that was given. You do not have to handle/catch
anything for this task, just note the errors.
I was expecting out of bounds error
Searching Confidence is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
#include <iostream>
int main() {
const int size = 5;
int arr[size];
// Attempt to store 100 at index 21 (which is out of bounds)
arr[21] = 100;
// The following line will not be executed due to the error above
std::cout << "This line will not be printed." << std::endl;
return 0;
}
But I am not getting any run time error .I am not understanding this.someone please help me.
Searching Confidence is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.