Write C program to find the maximum number from the n x m array.
//Write C program to find the maximum number from the n x m array.
main(void)
{
int Array[4][3] = {
{2, 30, 5},
{20, 10, 50},
{12, 42, 55},
{23, 7, 8}
};
int Max,n,m,r,c;
n = sizeof(Array)/sizeof(Array[0]);
m = sizeof(Array[0])/n;
Max = Array[0][0];
printf("\nInput Array:\n");
for(r=0;r<n;r++)
{
for(c=0;c<m;c++)
{
printf("%5d",Array[r][c]);
if(Array[r][c]>=Max) Max = Array[r][c];
}
printf("\n");
}
printf("\nGiven Array Size:\tn = %d, m = %d",n,m);
printf("\n\nThe maximum element in Array: %d",Max);
return(0);
}
Comments
Leave a comment