Posted By:
3 Oct, 2013 2:18 am PDT

Program in C++ to find the largest element of each row of a matrix

Write a program in C++ to find the largest element of each row of a matrix. The user can enter the size of the matrix.

Attachment:None


#include<stdio.h>
#include<conio.h>
 
void main()
{
   int m, n, c, d, matrix[10][10], maximum[10];
 
   printf("Enter the number of rows and columns of matrix\n");
   scanf("%d%d",&m,&n);
   printf("Enter the elements of matrix\n");
 
   for( c = 0 ; c < m ; c++ )
   {
      for( d = 0 ; d < n ; d++ )
      {
         scanf("%d",&matrix[c][d]);
      }
   }
 
   maximum[0] = matrix[0][0];
 
   for( c = 0 ; c < m ; c++ )
   {
      for( d = 0 ; d < n ; d++ )
      {
         if ( matrix[c][d] > maximum[c] )
            maximum[c] = matrix[c][d];
      }
   }
 
   printf("Maximum elements in each row in matrix is ");
for( c = 0 ; c < m ; c++ )
{
printf("max element in %d row is %d",++c,maximum[c]);
}
getch();
}


Was it useful?  




Please login to reply to this problem.



Related Problems on Fixoncloud