#include<stdio.h>
int main()
{
int array[100][100];/// declare a 2D Array.
int i,j,r,c;
printf("Please Enter The Row Number:");
scanf("%d",&r);
printf("Please Enter The Column Number:");
scanf("%d",&c);
printf("Please Enter %d X %d Element Of the array: ",r,c);
for(i=0; i<r; i++) ///scan array element
{
for(j=0; j<c; j++)
{
scanf("%d",&array[i][j]);
}
}
int max=0;
printf("The Maximum Element of the array:");
for(i=0; i<r; i++)
{
for(j=0; j<c; j++)
{
if(array[i][j]>max)///Checking the number is gather then max or not.
{
max=array[i][j];
}
}
}
printf("%d",max);
return 0;
}
Output
Please Enter The Row Number: 3
Please Enter The Column Number: 3
Please Enter 3 x 3 Element Of the array:
1 2 3
4 5 6
7 8 9
The Maximum Element of the array: 9
Add your comment