I was working on a problem, and tried to initialize an array to 0. Did this, arr[value] = {0}; When I declared an array, it seems to give a different output than what it supposed to give. Here is the code:
Code:
Case 1:
int count[2] = {0};
cout<<count[0];
cout<<count[1];
cout<<count[2];
Gives me output: 001
While, Case 2:
int count[3] = {0};
cout<<count[0];
cout<<count[1];
cout<<count[2];
cout<<count[3];
Gives me output: 0000
Why does this happen? Am I missing something? TIA.

