I figured it out. In the first example, I had two remove these two statements from the main loop, because the functions were not defined below. They did have prototypes, but the compiler didn't know what to do with them
Code:
printf("Average of elements in a[]: %f\n", average_of_elements(a, SIZE));
printf("Number of positive elements in a[]: %d\n", positive_element_count(a, SIZE));
This gave me more or less the result I was looking for. The exercise was just to create that array function to find the largest element in the array. I was having trouble getting it to work with the main loop
Code:
#include <stdio.h>
#define SIZE sizeof(a) / sizeof(a[0])
int largest_element(int a[], int length);
int main(void)
{
int i;
int a[10] = { 1, 3, 8, 20,12, 27, 0, 32, 12, 10 };
printf("a[] contains:");
for (i = 0; i < SIZE;i++)
printf("%d ",a[i]);
printf("\n");
printf("Largestelement in a[]: %d\n", largest_element(a, SIZE));
return 0;
}
/* Returns the largest element in a[] */
int largest_element(int a[], int length)
{
int i, largest = a[0];
for (i = 1; i < length;i++) {
if (a[i] > largest)
largest = a[i];
}
return largest;
}