The BOTTOM LINE Quote Of The Day

The BOTTOM LINE Quote Of The Day

Don't Ever Tell GOD How BIG Your Problems are.
Just Tell Your Problems How BIG your GOD is ;)

Monday, June 4, 2012

Finding Symmetric Matrix


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

int main()
  {
    int i,j,m,n,min;
    int mat[10][10];
    do
    {
    printf("\n Enter the no. of rows and columns : ");
    scanf("%d %d",&m,&n);
    }while(m!=n);

    for(i=0;i<m;i++)
    {
      printf("Row %d : ",i+1);          
      for(j=0;j<n;j++)
       scanf("%d",&mat[i][j]);  
    }
 
    for(i=1;i<m;i++)
    {        
     for(j=0;j<i;j++)
     {
       if(mat[i][j] != mat[j][i])
        break;            
     }  
    }  
 
    if(i == m && j+1 == i)
     printf("\n\nIt is a Symmetric Matrix");
    else
     printf("\n\nIt is not a Symmetric Matrix");
    getch();
    return 0;
  }

No comments:

Post a Comment