#include<stdio.h>
#include<stdlib.h>
int main()
{
int **p;
int i,j,k,l,m,n;
printf("\n Enter number of rows:");
scanf("%d",&m);
printf("\n Enter number of columns:");
scanf("%d",&n);
p=(int**) malloc(m * sizeof(int*));
for(i=0;i<m;i++)
{
p[i]=(int*) malloc(n * sizeof(int));
}
printf("\n Enter %d by %d matrix:",m,n);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&p[i][j]);
}
}
l=p[0][0];
k=p[0][0];
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(l<p[i][j])
l=p[i][j];
if(k>p[i][j])
k=p[i][j];
}
}
printf("\n %d by %d matrix is:\n\n",m,n);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d ",p[i][j]);
}
printf("\n");
}
printf("\n The Greatest elements in matrix=%d",l);
printf("\n The Smallest elements in matrix=%d",k);
return 0;
}
****INPUT && OUTPUT****
0 Comments