#include #include #include #include /* Demonstration of arrays in C. Compiles on a UNIX system using gcc -lm -Wall -o C-examples-3 C-examples-3.c Execute from the shell using "C-examples-3" or "./C-examples-3". */ /***************************************************************************** 1-dimensional arrays (vectors) ******************************************************************************/ /* Returns the sum of the values in X, where X is an array with length n. */ double sum(const double* X, const int n) { int i; double S = 0; for (i=0; i0; --i) X[i] -= X[i-1]; } /* Returns the p-norm length of X, where X has length n. */ double pnorm(const double* X, const int n, const double p) { int i; double L = 0; for (i=0; i M) ? X[i] : M; return M; } /* Returns the index of the smallest value in X, where X has length n. */ int minloc(const double* X, const int n) { int i, L=0; for (i=1; i