/ Compute average of an array concise pointer version. * double table average(int a[], int n) double sum =0.0; /* running total * int ptri /* traversing pointer * int *endptr a n; / pointer to just past end * for (ptr ai ptr endptri ptr++) sum + *ptri return (n 0)? sum/n: 0.0 int *endptr atn it does not mean endptr +n; but endptr a+n 七 endptr a+ n; it assign a n to endptr PROGRAM MINGMETHDOLODGY AND SOFTWAREENGINEERING 港城市大 Copyrighto1998 Angus Wu ol Hone KonePROGRAMMING METHDOLODGY AND SOFTWARE ENGINEERING Copyright©1998 Angus Wu /* Compute average of an array, concise pointer version.*/ double table_average(int a[], int n) { double sum = 0.0; /* running total */ int *ptr; /* traversing pointer */ int *endptr = a + n; /* pointer to just past end */ for (ptr = a; ptr < endptr; ptr++) sum += *ptr; return (n != 0) ? sum / n : 0.0; } int *endptr = a + n; it does not mean *endptr = a + n; but endptr = a + n; int *endptr = a + n; it assign a + n to endptr