EmbLogic's Blog

Write a Program to Subtract two matrix?

code :

#include<stdio.h>
#include<stdlib.h>
int main()
{
system(“clear”);
int r,c,i,j,a[10][10],b[10][10],d[10][10];
printf(“Enter Row\n”);
scanf(“%d”,&r);
printf(“Enter Column\n”);
scanf(“%d”,&c);
printf(“Enter Element of Matrix1\n”);
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
scanf(“%d”,&a[i][j]);
}
}
printf(“Enter Element of Matrix2\n”);
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
scanf(“%d”,&b[i][j]);
}
}
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
d[i][j]=a[i][j]-b[i][j];
}
}
printf(“Subtraction of two Matrixs\n”);
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf(“%d-%d=%d\n”,a[i][j],b[i][j],d[i][j]);
}
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>