Introduction
  • In this blog, I am going to explain how to add two matrices in C programming, by entering the order of matrix. 
Software Requirements
  • Turbo C++ or C.
Programming
  1. #include < stdio.h >   
  2. int main()  
  3. {  
  4.     int m, n, c, d, first[10][10], second[10][10], sum[10][10];  
  5.     printf("Enter the number of rows and columns of matrix\n");  
  6.     scanf("%d%d", & m, & n);  
  7.     printf("Enter the elements of first matrix\n");  
  8.     for (c = 0; c < m; c++)  
  9.         for (d = 0; d < n; d++) scanf("%d", & first[c][d]);  
  10.     printf("Enter the elements of second matrix\n");  
  11.     for (c = 0; c < m; c++)  
  12.         for (d = 0; d < n; d++) scanf("%d", & second[c][d]);  
  13.     printf("Sum of entered matrices:-\n");  
  14.     for (c = 0; c < m; c++)  
  15.     {  
  16.         for (d = 0; d < n; d++)  
  17.         {  
  18.             sum[c][d] = first[c][d] + second[c][d];  
  19.             printf("%d\t", sum[c][d]);  
  20.         }  
  21.         printf("\n");  
  22.     }  
  23.     return 0;  
  24. }  
Explanation
  •  By the above programming, the sum of two matrices can be printed successfully.

     programming

    programming
Output

Output