I’ve recently started studying c programming and I have a piece of code but cannot figure out how it gives me the result.
int i, j, v, a(6) = {1, 3, 1, 3, 1, 3};
for (i=0; i<5; i++)
{
v = 0;
for (j=0; j<2; j++)
{
v += a(i+j);
}
printf("%d,", v/2);
}
It prints out 2,2,2,2,2, but I don’t know why. Can someone explain? I know it’s an easy task but I’m a rookie in coding.