// ex_ch10_5.c
#include <stdio.h>
#define SIZE 5
/* simulates infinity */
#define BIGGEST 1000
#define SMALLEST -1 * BIGGEST

double amplitude(const double arr[], int n);

int main(void)
{
	const double values[SIZE] = {4.4, 6.6, 1.1, 3.3, 2.2};

	printf("The difference between the largest and the smallest "
	       "is %.2f.\n", amplitude(values, SIZE));
	
	return 0;
}

double amplitude(const double arr[], int n)
{
	double max, min;
	int i;
	max = SMALLEST;
	min = BIGGEST;
	
	for (i = 0; i < n; i++)
	{
		if (arr[i] > max)
			max = arr[i];
		if (arr[i] < min)
			min = arr[i];
	}
	
	return max - min;
}
