Example output
The error occurs because arr is a one-dimensional array and is being treated as a two-dimensional array. The code should be changed to:
int arr[2];
for (int i=0; i<2; i++){
arr[i] = 1;
}
Alternatively, if the code is supposed to be two-dimensional, it should be defined as such:
int arr[2][2];
for (int i=0; i<2; i++){
arr[i][0] = 1;
}