Quote Originally Posted by supermeew
as suggested ealier i plugged in 0s at the start and end of the array
I don't think that was the suggestion. My suggestion was to see what happens to i-1 and i+1 when i=0 and i=7, and whether you get indices of, say, -1 or 8 when you can only go from 0 to 7. But changing the loop to go from 1 to MAX-1 was the way to go. Note that the calculation cannot be done at the endpoints of the array. And by the way, if you are using MAX, don't later use a hard-coded 8. Frankly I don't care to use #defines this way.

As far as defining another function, I might suggest starting with something like this.
Code:
#include <stdio.h>

void foo(const int *a, size_t size, int *z)
{
   size_t i;
   puts("foo");
   for ( i = 1; i < size - 1; ++i )
   {
      z[i] = a[i-1] - (2 * a[i]) + a[i+1];
      printf("z[%d] = %d\n", (int)i, z[i]);
   }
}

int main(void)
{
   int a[] = {-5,-1,23,115,347,815,1639,2963};
   int b[] = {0,2,5,7,4,3,5,9,8,0};
   int z[sizeof b / sizeof *b]; /* same size as the bigger b array */
   foo(a, sizeof a / sizeof *a, z);
   foo(b, sizeof b / sizeof *b, z);
   return 0;
}

/* my output
foo
z[1] = 20
z[2] = 68
z[3] = 140
z[4] = 236
z[5] = 356
z[6] = 500
foo
z[1] = 1
z[2] = -1
z[3] = -5
z[4] = 2
z[5] = 3
z[6] = 2
z[7] = -5
z[8] = -7
*/