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

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


#include<stdio.h>

float small(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 = small(a,m,n);
 
 printf("Smallest = %f\n", res);
 
 return 0;
}

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