On line 7 of the following example, the function find_max is declared as having type void. Lines 15 through 26 contain the complete definition of find_max.
Note: The use of the sizeof operator in line 13 is a standard method of determining the number of elements in an array.
1 /** 2 ** Example of void type 3 **/ 4 #include <stdio.h> 5 6 /* declaration of function find_max */ 7 extern void find_max(int x[ ], int j); 8 9 int main(void) 10 { 11 static int numbers[ ] = { 99, 54, -102, 89 }; 12 13 find_max(numbers, (sizeof(numbers) / sizeof(numbers[0]))); 14 15 return(0); 16 } 17 18 void find_max(int x[ ], int j) 19 { /* begin definition of function find_max */ 20 int i, temp = x[0]; 21 22 for (i = 1; i < j; i++) 23 { 24 if (x[i] > temp) 25 temp = x[i]; 26 } 27 printf("max number = %d\n", temp); 28 } /* end definition of function find_max */