fork download
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int n,m;
  5. scanf("%d %d", &n, &m);
  6. printf("Enter values of matrix 1: \n");
  7. int array1[n][m];
  8. for(int i=0; i<n; i++){
  9. for(int j=0; j<m; j++){
  10. scanf("%d", &array1[i][j]);
  11. }
  12. }
  13. printf("Enter values of matrix 2: \n");
  14. int array2[n][m];
  15. for(int i=0; i<n; i++){
  16. for(int j=0; j<m; j++){
  17. scanf("%d", &array2[i][j]);
  18. }
  19. }
  20.  
  21. for(int i=0; i<n; i++){
  22. for(int j=0; j<m; j++){
  23. if(array1[i][j] != array2[i][j]){
  24. printf("Matrix is not same.");
  25. return 0;
  26. }
  27. }
  28. }
  29. printf("Both Matrix is same.");
  30. }
  31.  
  32.  
Success #stdin #stdout 0.01s 5272KB
stdin
2 2
Enter values of matrix 1:
3 3
4 4
Enter values of matrix 2:
5 5
1 2
stdout
Enter values of matrix 1: 
Enter values of matrix 2: 
Matrix is not same.