Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

anni11's blog

By anni11, history, 8 years ago, In English

Hello friends, although this is a silly doubt but i have faced some problems because of this.

I have seen that many coders when they code their solutions ,they use the arrays they have declared without initializing it with zero i.e. they write code as if the array already contains zero at all indices while i initialize it with zero, so my doubt is that when we declare a 1-D array or 2-D array or any N-D array then is it automatically initialized with zero at all locations or some random values. And is it always true in all the online judges or do we need to initialize it with zero to eliminate the random values ? For eg when i write the following :

int a[10];

for(int i = 0; i < 10; ++i) cout << a[i] << endl;

I get random values and sometimes zero. Could anyone tell me what is exactly happening. Thanks.

Full text and comments »

  • Vote: I like it
  • +11
  • Vote: I do not like it