// sequential search for a maximum number

#include <iostream>
#include <cstdlib>			// rand & srand
#include <ctime>			// time
using namespace std;

const int LENGTH = 5;			// length of the array

int main()
{
	int numbers[LENGTH];// test scores
	int i = 0;			// loop variable
	int maxValue = 0;		// maximum value in the array

	for (i = 0; i < LENGTH; i++)
	{
		numbers[i] = rand() % 50 + 1;
		cout << numbers[i] << " ";
	}

	for (i = 0; i < LENGTH; i++)	// linear search for max value
	{

		if (numbers[i] > maxValue)	// if next number is greater than the max found so far...
		{
			maxValue = numbers[i];  // ...replace the max found so far with this new value
		}

	}
	
	cout << "The max value in the array is " << maxValue << endl;
	
	system("pause");

	return 0;
}// end of main
