Algorithms/Find maximum/c method 1

c source code

int findmax(const int a[], int len) {
	int curr_max, i;
 
	if(len == 1)
		return a[0];
	else if(len == 0)
		return 0;
 
	curr_max = a[0];
	for(i = 1; i < len; i++)
		if(a[i] > curr_max)
			curr_max = a[i];
 
	return curr_max;
}
Last modified on 2 November 2013, at 18:21