A C program to find largest element and its position of a matrix
#include<stdio.h>
#include<conio.h>
void main()
{
int m[100][100],i,j,rw,co,nr=0,nc=0,l;
clrscr();
printf("\nHow many ROW and COLUM\n");
scanf("%d%d",&rw,&co);
printf("\nEnter the matrix\n");
for(i=0;i<rw;i++)
{
for(j=0;j<co;j++)
{
scanf("%d",&m[i][j]);
}
}
clrscr();
printf("\n\tThe Given Matrix is \n");
for(i=0;i<rw;i++)
{
for(j=0;j<co;j++)
{
printf("%d ",m[i][j]);
}
printf("\n");
}
l=m[0][0];
for(i=0;i<rw;i++)
{
for(j=0;j<co;j++)
{
if(l<m[i][j])
{
l=m[i][j];
nr=i;
nc=j;
}
}
}
printf("\n\nThe largest element is ::%d \n",l);
printf("\nIT is in %d th row and %d th colum ",nr+1,nc+1);
getch();
}
|