Home
> C Examples > write a program to find a square matrix is symmetric.

## write a program to find a square matrix is symmetric.

#include<stdio.h> main() { int i,j,a[10][10],b[10][10],n,temp; printf("\nEnter the dimensions of matrix:: "); scanf("%d",&n); printf("\nEnter the eleents of matrix::\n"); for(i=0;i<n;i++) for(j=0;j<n;j++) scanf("%d",&a[i][j]); printf("\nOriginal Matrix is:: "); for(i=0;i<n;i++) { printf("\n"); for(j=0;j<n;j++) printf("\t%d",a[i][j]); } for(i=0;i<n;i++) for(j=0;j<n;j++) {b[j][i]=a[i][j]; } printf("\nTranspose Matrix is:: "); for(i=0;i<n;i++) { printf("\n"); for(j=0;j<n;j++) printf("\t%d",b[i][j]); } for(i=0;i<n;i++) { for(j=0;j<n;j++) {if(a[i][j]!=b[i][j]) { printf("\nMatrix is not symmatric :(\n"); exit(0); } } } printf("\nMatrix is symmatric :)\n"); }

Categories: C Examples
C code, square matrix, symmetric matrix

Pretty nice post. I just stumbled upon your blog and wanted to say that I have really enjoyed browsing your blog posts. In any case I’ll be subscribing to your feed and I hope you write again soon!