Wednesday, 13 August 2014

// SYMMETRIC MATRIX
// CODE
#include<stdio.h>
#include<conio.h>
clrscr();
main()
{
  int a[10][10],i,j,r,c,flag;
  printf("Enter the rows of the matrix:");
  scanf("%d",&r);
  printf("Enter the columns of the matrix:");
  scanf("%d",&c);
  if(r==c)
  {
          printf("\n Enter the values of matrix a:");
          for(i=0;i<r;i++)
          {
            for(j=0;j<c;j++)
            { 
               scanf("%d",&a[i][j]);
            }
          }   
            flag=0;
            for(i=0;i<r;i++)
            {
               for(j=0;j<c;j++)
               {
                  if(a[i][j]!=a[j][i])
                  {
                     flag=1;
                     break;
                  }
               }
               break;
            } 
            if(flag==1)
            {
               printf("\n Not symmetric matrix");
            } 
            else
            {
                printf("\n A symmetric matrix");
            }   
   }       
   else
   {
       printf("\n Invalid matrix");
   }  
   getch();
   return 0;
}
 //OUTPUT
Enter the rows of the matrix:3
Enter the columns of the matrix:3
Enter the values of the matrix:1
2
3
4
5
6
7
8
9
A symmetric matrix
 

No comments:

Post a Comment

Note: only a member of this blog may post a comment.