/* array code */
/* return A[0]+..+A[n-1] */
int sum1 (int* A, int n) {
  int i;
  int sum = 0;
  for (i = 0; i < n; i++)
    sum += A[i];
  return sum;
}

/* pointer code */
/* warning: do not write this---this is poor style */
/* return A[0]+..+A[n-1] */
int sum2 (int* A, int n) {
  int* end = A + n;
  int sum = 0;
  while (A < end) {
    sum += *A;
    A++;
  }
  return sum;
}

int main () {
  int A[5] = {2,3,5,7,11};
  printf("sum1 = %d\n", sum1(A, 5));
  printf("sum2 = %d\n", sum2(A, 5));
}
