Program to Check for symmetric matrix


# include <iostream.h>
# include<conio.h>
void main( )
{
    int i, j, matrix[3][3], flag = 0;
    cout<<"\n Input 3 × 3 matrix  elements :\n";
    for (i=0;i<3;i++)
        for(j=0;j<3;j++)
                  cin>>matrix[i][j];
    for (i=0;i<3;i++)
        for(j=0;j<3;j++)
                  if (matrix[i][j] != matrix[j][i])
                    flag = 1;
    if (flag == 1)
            cout<<"\n Matrix is not symmetric";
    else
             cout<<"\n Matrix is symmetric";
}

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|