Simple array use example, simple array use example
/* ===================================================== ============================================================ Name: testArray. c Author: lf Version: Copyright: Your copyright notice Description: simple array use example ====================================================== ========================================================== = */# include <stdio. h> # include <stdlib. h ># define SIZE 5 # define NUM 5 void getAverage (); void searchMax (); int main (void) {getAverage (); // searchMax (); return EXIT_SUCCESS ;} /*** get the average of several numbers */void getAverage () {int total = 0; int intArray [SIZE]; int I; for (I = 0; I <SIZE; I ++) {scanf ("% d", & intArray [I]); total = total + intArray [I];} printf ("total = % d \ n ", total); printf ("average = % d", total/SIZE);}/*** find the maximum value in the array */void searchMax () {int result = 0; int array [NUM]; int I; for (I = 0; I <NUM; I ++) {scanf ("% d", & array [I]);} result = array [0]; int j; for (j = 1; j <NUM; j ++) {if (array [j]> result) {result = array [j] ;}} printf ("max = % d", result );}