/*
The following program declares a two-dimensional array of 4 rows and 4 
columns, reads it, and with the help of a function called findMax, it 
finds the maximum element of the main diagonal of the array.
*/ 
#include <iostream>
using namespace std;
float findMax(float [][4], int);
int main()
{
	float a[4][4], sum = 0;
	int i, j;
	cout << "Enter the array: \n";
	for (i = 0; i < 4; i++)
		for (j = 0; j < 4; j++)
			cin >> a[i][j];
	
	cout << "The maximum of the main diagonal is: "
		<< findMax(a,4) << endl;
	
	return 0;
}

float findMax(float a[][4], int rows)
{
	int i;
	float max = a[0][0];
	for (i = 0; i < rows; i++)
			if (a[i][i] > max)
				max = a[i][i];
	return max;
}
