Hi i have 2 function for reversing arrays. One work and the other doesn't. can help me analyse why the first is wrong?

The above can't work.Code:void reverse_array(int arr[], int length) { int i,j; for(i=length; i>0; i--) for(j=0; j<length; j++) { arr[j]=arr[i]; printf("%d ", arr[j]); } }

this works (why they use length/2 ??)Code:void reverse_array(int arr[], int length) { int i, temp; for (i=0; i<length/2; i++) { temp = arr[i]; arr[i] = arr[length-i-1]; arr[length-i-1] = temp; } }

thanks!