program to find median using pointers