/*PROGRAM TO FIND BIGGEST AND SMALLEST ELEMENT IN THE MATRIX BY PASSING MATRIX TO A FUNCTION*/
#include<conio.h>
#include<iostream.h>
class big_small
{
int m,n,i,j,a[5][5],big,small;
public:
void input();
void output(int a[5][5],int,int);
};
void big_small::input()
{
cout<<“Enter the order of the matrix: “;
cin>>m>>n;
cout<<“Enter “<<m*n<<” Elements in the matrix: \n”;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cin>>a[i][j];
}
}
output(a,m,n);
}
void big_small::output(int a[5][5],int m,int n)
{
cout<<“Entered matrix is:\n”;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
cout<<a[i][j]<<” “;
cout<<‘\n’;
}
big=a[0][0];
small=a[0][0];
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(a[i][j]>big)
big=a[i][j];
if(a[i][j]<small)
small=a[i][j];
}
}
cout<<“Biggest element in the matrix is: “<<big<<endl;
cout<<“Smallest element in the matrix is: “<<small;
}
void main()
{
big_small bs1;
clrscr();
bs1.input();
getch();
}