C Program: Largest Element from Matrix (User Defined Function)

Question: Write a program in C to read m x n matrix and find largest element from it using user defined functions.


#include<stdio.h>


float large(float a[10][10], int m, int n);

int main()
{
 int i,j,m,n;
 float a[10][10], res;

 printf("Enter row and column size:\n");
 scanf("%d%d", &m, &n);
 printf("Enter matrix elements:\n");
 for(i=0;i< m;i++)
 {
  for(j=0;j< n;j++)
  {
   printf("a[%d][%d]=",i,j);
   scanf("%f", &a[i][j]);
  }
 }
 res = large(a,m,n);
 printf("Largest = %f\n", res);
 
 return 0;
}


float large(float a[10][10], int m, int n)
{
 int i,j;
 float lg = a[0][0];
 for(i=0;i< m;i++)
 {
  for(j=0;j< n;j++)
  {
   if(a[i][j]>lg)
   {
    lg = a[i][j];
   }
  }
 }
 return(lg);
}