WAP in C for subtraction of two matrices?

#include<stdio.h>
#include<conio.h>
int main()
{
int m, n, c, d, a[10][10], b[10][10], e[10][10];
clrscr();
printf(“Enter the number of rows and columns of matrix\n”);
scanf(“%d%d”, &m, &n);
printf(“Enter the elements of first matrix\n”);
for (c = 0; c < m; c++)
for (d = 0 ; d < n; d++)
scanf(“%d”, &a[c][d]);
printf(“Enter the elements of second matrix\n”);
for (c = 0; c < m; c++)
for (d = 0; d < n; d++)
scanf(“%d”, &b[c][d]);
printf(“Difference of entered matrices:-\n”);
for (c = 0; c < m; c++)
{
for (d = 0; d < n; d++)
{
e[c][d] = a[c][d] – b[c][d];
printf(“%d\t”,e[c][d]);
}
printf(“\n”);
}
getch();
return(0);
}

Output :-

submatrix

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s