/* * To input 2 matrices of order 2 X 3 and check if they are the same * @author-Karan Narain(karan@iitk.ac.in) * */ #include int main() { int A[2][3],B[2][3],i,j,same; printf("Enter the first 2 X 3 matrix\n"); for(i=0;i<2;i++) for(j=0;j<3;j++) scanf("%d",&A[i][j]); printf("Enter the second 2 X 3 matrix\n"); for(i=0;i<2;i++) for(j=0;j<3;j++) scanf("%d",&B[i][j]); //Initialize same to 1 same=1; for(i=0;i<2;i++) { for(j=0;j<3;j++) { if(A[i][j]!=B[i][j]) { /*As soon as the first different element is encountered,set same=0 and stop checking further elements as the matrices cannot be same*/ same=0; break; } } } //If all elements are the same if(same==1) printf("The two matrices are same\n"); //If even 1 element is different else printf("The two matrices are different\n"); return 0; }