Addition , Subtraction and Multiplication of Matrices

Sample C Program : Addition , Subtraction and Multiplication of Matrices, This program receives input of two matrices and performs the basic operations>/p>

  1. /* Addition , Subtraction and Multiplication of Matrices */
  2. #include<stdio.h>
  3. /*Getting the element of the Matrix1 */"Enter the order of first matrix\n");
  4. scanf("%d %d""%d %d""\n Enter the element of first matrix\n""%d", &a[i][j]);
  5. }
  6.  
  7. /*Getting the element of the Matrix2 */"\n Enter the order of second matrix\n");
  8. scanf("%d %d ""%d %d\n""\n Enter the element of second matrix\n""%d""\n");
  9. /* Displaying Matrix1 and Matrix2 */"\n\t\t Addition, Subtraction, Multiplication of Matrixes\n\n""First matrix:\n""\t%d""\n""\n""Second Matrix: \n""\t%d""\n"/*Checks whether the orders of the Matrixes are equal */
  10. {
  11. add(a,b,m,n); /*If equal sends to the functions add & mul *//* If columns(Mat.1) = Rows (Mat.2) it Multiplication only possible */"\n Addition and Subtraction not possible with this order""\n The order of the matrix are not proper""\n\t The product: \n""\t\t %d""\n\n""\n""\t The sum:\n""\t%d\t""\n\n""\t The difference:\n""\t%d\t""\n\n");
  12. }
  13.  
  14. }