/*
Declare a one-dimensional array of type float and of maximum size 100.
Then ask the user to enter the actual size of the array (the number of
elements that will be used). The read the array. Then find the maximum
(largest) element of the array by using a function.
*/ 
#include <iostream>
using namespace std;
float findMax(const float[], int n);
int main()
{
	int i, n;
	float  a[100], max;
	cout << "Enter the actual size: ";
	cin >> n;
	if (n <= 100)
	{
		cout << "Enter the array: ";
		for (i=0; i < n; i++)
			cin >> a[i];
		max = findMax(a,n);
		cout << "The largest element is: " << max << endl;
		cout << "The array is: " << endl;
		for (i=0; i < n; i++)
			cout << a[i] << '\t';
		cout << endl;
	}
	else
		cout << "Invalid input: size must be < 101.\n";
	return 0;
}

float findMax(const float b[], int n)
{
		int i;
		float max = b[0];
		for (i = 1; i < n; i++)
			if (b[i] > max)
				max = b[i];
		//b[0] = 100;
		return max;
}
