A program to find the maximum element of a matrix
C Programming Language 060
The following code shows how to write a program to find the maximum element of a matrix.
Program
#include <stdio.h>
void main()
{
int a[10][10], m, n, i, j, max = 0;
printf("Enter order m,n [m x n]: ");
scanf("%d %d", &m, &n);
printf("Enter values:\n");
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
scanf("%d", &a[i][j]);
if (a[i][j] > max)
{
max = a[i][j];
}
}
}
printf("Maximum = %d", max);
printf("\n");
}
Result
Enter order m,n [m x n]: 2 3
Enter values:
1 2 3
4 5 6
Maximum = 6
Last Updated on
Comments