#include<stdio.h>
int findMax(int **,int m,int n);
int main()
{
int n;
int a[20][20];
int i, j, max;
printf("\nEnter the number of rows in the array");
scanf("%d", &m);
printf("\nEnter the number of columns in the array");
scanf("%d", &n);
printf("\nEnter the elements of the matrix");
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
scanf("%d", a[i][j]);
}
printf("\n");
}
printf("\nThe matrix is\n");
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
printf("%d", a[i][j]);
}
printf("\n");
}
max = findMax((int **)a, m, n);
printf("\nThe maximum element in the matrix is %d", max);
return 0;
}
int findMax(int **a, int m, int n)
{
int i, j, max;
max = a[0][0];
for(i=1; i<=m; i++)
{
for(j=1; j<=n; j++)
{
if(a[i][j] > max)
max = a[i][j];
}
}
return max;
}
The program should display the maximum element in the matrix. The maximum value should be found in the function block. While executing this program the control is passed to the function block, but the values aren't assigned and the entire block doesn't get executed and the program is terminated. What is wrong in this program?