// ex_ch10_3.c -- finds the largest value of an int[]
#include <stdio.h>
#define SIZE 5

int largest(const int arr[], int n);

int main(void)
{
	const int values[SIZE] = {4, 6, 1, 3, 2};

	printf("The largest value is %d.\n", largest(values, SIZE));
	
	return 0;
}

int largest(const int arr[], int n)
{
	/* this is somehow broken cause it does not deal with negative
	   numbers */
	int current_largest = 0, i;
	
	for (i = 0; i < n; i++)
		if (arr[i] > current_largest)
			current_largest = arr[i];
	
	return current_largest;
}
