Read what you wrote:
Ouput Explanation- at 0th index value is 4 so we have to check the value at index 4 and square it which means 0x0=0 , and place the value at 0th index in same array
So do that: get the value at the loop variable index, and use that value as an index into the array - then square that value and store back in the array using the loop variable as an index again.
All your code does is get the value at the look variable index, square it, and store that in a different array.