#include<stdio.h>
int findMax(int **a,int m,int n)
{
int max,i,j;
max=a[0][0];
for(i=0;i<m;i++)
for(j=0;j<n;j++)
if(max<a[i][j])
max=a[i][j];
return max;
}
int main()
{
int a[20][20],m,n,i,j,maxim;
scanf("%d",&m); //Rows
scanf("%d",&n); //Cols
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
maxim=findMax((int **)a,m,n);
printf("Max is %d\n",maxim);
return 0;
}
The above code must give the maximum element in the input matrix.
PROBLEM
When the code is compiled, i'm not getting any error or warning, But DURING EXECUTION the code just stops running after taking the input.!
The problem statement says that int findMax(int **a,int m,int n) has to be used.