Subtraction of Two Matrices

Subtraction of Two Matrices


C Program for subtraction of two matrices 

#include<stdio.h>
#include<conio.h>

//Read Matrix
void read_mat(float a[][10],int m,int n)
{
int i,j;
printf("\n\nEnter %d X %d matrix below:\n",m,n);
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%f",&a[i][j]);
}

//Write Matrix
void write_mat(float a[][10],int m,int n)
{
int i,j;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
printf("%10.2f",a[i][j]);
printf("\n");
}
}

//Subtract matrices
void sub_mat(float a[][10],float b[][10],float c[][10],int m,int n)
{
int i,j;
for(i=0;i<m;i++)
for(j=0;j<n;j++)
c[i][j]=a[i][j] - b[i][j];
}

//main function
void main()
{
float x[10][10],y[10][10],z[10][10];
int m,n;
clrscr();

//Accept two matrices
printf("\n\nEnter order of matrix \n");
scanf("%d %d",&m,&n);
read_mat(x,m,n);
read_mat(y,m,n);

//call sub_mat() function
sub_mat(x,y,z,m,n);
printf("\n\nSUBTRACTION OF THE GIVEN MATRICES IS:\n");
write_mat(z,m,n);
getch();
}

9 comments:

  1. 2)Subtraction of Two Matrices
    https://drive.google.com/open?id=0B5pG0kIjzgEKOXY3aU9FdmREems

    ReplyDelete
  2. ID 201610456
    link->
    https://drive.google.com/open?id=1C260hEUSezqr4mFdjpStkAkpnJVCaAk4zcKHZfa9f6g

    ReplyDelete
    Replies
    1. Subtraction of 2 dimension array using multilevel inheritance
      ID201610456
      link->
      https://drive.google.com/open?id=0B_PIGnOMR0K2ZWx0cTdfTk5mN2c

      Delete
    2. ID 201610456
      subtraction of 2 dimensional matrix using multilevel inheritance
      link->
      http://ideone.com/E2Sxu4

      Delete
  3. ID : 201620195
    https://www.dropbox.com/s/0sk027rqgq3kb81/02.cpp?dl=0

    ReplyDelete
  4. Subtruction of two dimension array following multilevel inheritance
    ID 201610456
    link->
    https://drive.google.com/open?id=0B_PIGnOMR0K2ZWx0cTdfTk5mN2c

    ReplyDelete
  5. ID: 201710494
    https://www.dropbox.com/s/jbvbgoe5xjdco67/2%20Multilevel%20Inheritance.cpp?dl=0

    ReplyDelete
  6. http://www.c-programming-blog.com/2014/12/subtraction-of-two-matrices.html?m=1

    ReplyDelete
  7. http://www.c-programming-blog.com/2014/12/subtraction-of-two-matrices.html?m=1

    ReplyDelete