float dotprod(int n, float x[], float y[]) { int i; float sum = 0; for (i = 0; i < n; ++i) { sum += x[i]*y[i]; } return sum; }