/*
The following program declares a two-dimensional array of 4 rows and 4 
columns, reads it, and with the help of a function called findAvg, it finds 
the average of the main diagonal of the array.
*/
#include <iostream>
using namespace std;
float findAvg(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 average of the main diagonal is: "
		<< findAvg(a,4) << endl;
	
	return 0;
}

float findAvg(float a[][4], int rows)
{
	int i;
	float sum = 0;
	for (i = 0; i < rows; i++)
			sum += a[i][i];
	return sum / rows;
}
