I am creating a 2-D array. However, when I use a double for-loop to check the contents of my 2-D array, it is filled with random numbers. I know that I can use a double for-loop to manually fill my double array with 0's. However, I am confused on why it does not do this when it is initialized.
int arr[5][5];
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
cout << arr[i][j] << " ";
}
cout << endl;
}
output:
0 0 0 0 0
0 0 0 -272632592 32766
-272632616 32766 0 1 0
0 0 0 0 0
0 0 0 0 -272632608
Program ended with exit code: 0