Why does the value of sum changes after for loop in the following code even after I have initialised it as 0 in CodeBlocks?
int main()
{
int a[5], i, sum;
sum= 0; // value of sum is not changed after this.
printf("\nSum=%d", sum);
for( i=1; i<6; i++)
{
printf("\n\nInput %d: ", i);
scanf("%d", &a[i]);
printf("Sum test=%d", sum);
}
printf("\n\nSum=%d", sum); // why does it changes?
return 0;
}
