Why in example 1 code it assigns 0s in non initialized items of array, but in example 2 assigns random numbers in completely non initialized array? Why it dont assign 0s to completely non initialized array as well?
Example 1:
int ar[5] ={0,1};
for (int i =0; i< 5; i++){
cout << ar[i] << " ";
}
// output: 0 1 0 0 0
Example 2:
int ar[5] ;
for (int i =0; i< 5; i++){
cout << ar[i] << " ";
}
// output: 1875998720 0 1875947552 0 1876031856