A Program to check whether entered matrix is symmetric or not. Code: #include<stdio.h> #include<conio.h> main() { int a[10][10],at[10][10],k,i,j,m,n; clrscr(); printf("enter the order of matrix"); scanf("%d %d",&m,&n); printf("enter the matrix"); for(i=0;i<m;i++) { for(j=0;j<n;j++) scanf("%d",&a[i][j]); } for(i=0;i<m;i++) { for(j=0;j<n;j++) at[i][j]=a[j][i]; } for(i=0;i<m;i++) { for(j=0;j<n;j++) { if(at[i][j]!=a[i][j]) k=1; } } if(k==1) printf("not symmetric"); else printf("symmetric"); getch(); }
Hello, shabbir. I alos facing the same problem. I have read some of the article mentioned that conio.h is a dos function. That's the MS VC++ 6.0 complaint the error. I think the conio.h(clrscr()) is compiled in borland and Turbo++ IDE. BY the way, how to add the file so that my compiler is able to accessed the file(conio.h) in MS VC++ 6.0 . Your help is greatly appreciated by me and others. Thanks for your help.
Then how to add the clrscr() function so that the VS compiler can accessed the header file. Thanks for your help.
clrscr function is not defined in the header file used by the VC compiler and if you manage to use the other header file you will not be able to get the correct implementation.
Code: #include<stdio.h> #include<conio.h> void main() { int a[10][10]; int i,j,n,m,sym=1; clrscr(); printf("Enter the order of matrix\n"); scanf("%d%d",&m,&n); if(m==n) { printf("Enter the matrix elements\n"); for(i=0;i<m;i++) for(j=0;j<n;j++) scanf("%d",&a[i][j]); for(i=0;i<m;i++) for(j=0;j<n;j++) { if(a[i][j]!=a[j][i]) { sym=0; } } printf("Matrix\n"); for(i=0;i<m;i++) { for(j=0;j<n;j++) printf("%d\t",a[i][j]); printf("\n"); } if(sym==1) printf("is a symmetric matrix\n"); else printf("is not a symmetric matrix\n"); } else printf("Not a square matrix\n"); getch(); }
Instead of using clrscr() from conio.h header, you can try "system("cls");" ( without ""). I'm using dev-C++ and it works. clrscr() is not ANSI, so you can't use it on C++ ANSI compiler.