Storing Largest Element of Each Row From mxn Matrix to One Dimensional Array

Question: Write a program to read a mxn matrix of integers and to find largest element of each row. Store the largest elements of the row in a one-dimensional array of m integers before displaying them.

Program


#include<stdio.h>
#include<conio.h>

int main()
{
 int array[10][10], large[10], m, n, i, j, temp;
 clrscr();
 printf("Enter row and column of matrix:\n");
 scanf("%d%d", &m, &n);
 /* Reading Matrix */
 for(i=0;i< m;i++)
 {
  for(j=0;j< n;j++)
  {
   printf("a[%d][%d] = ", i, j);
   scanf("%d", &array[i][j]);
  }
 }
 /* Finding Largest and Storing in One Dimensional Array */
 for(i=0;i< m;i++)
 {
  temp = array[i][0];
  for(j=0;j< n;j++)
  {
   if(array[i][j]>temp)
   {
    temp = array[i][j];
   }
  }
  large[i] = temp;
 }
 /* Displaying Large Array */
 printf("Largest elements from each row are:\n");
 for(i=0;i< m;i++)
 {
  printf("%d\t", large[i]);
 }
 getch();
 return 0;
}