Program to subtract the given two matrices
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int mata[10][10], matb[10][10], matc[10][10];
int i, j, row, col;
clrscr();
printf("Enter the order of the matrix : ");
scanf("%d %d", &row, &col);
printf("\nEnter the elements of first matrix : \n\n");
for(i = 0; i < row; i++)
for(j = 0; j < col; j++)
scanf("%d", &mata[i][j]);
printf("\nEnter the elements of second matrix : \n\n");
for(i = 0; i < row; i++)
for(j = 0; j < col; j++)
scanf("%d", &matb[i][j]);
for(i = 0; i < row; i++)
for(j = 0; j < col; j++)
matc[i][j] = mata[i][j] - matb[i][j];
printf("\nThe resultant matrix is : \n\n");
for(i = 0; i < row; i++)
{
for(j = 0; j < col; j++)
{
printf("%d \t", matc[i][j]);
}
printf("\n");
}
getch();
}
Output:
Enter the order of the matrix : 3 3
Enter the elements of first matrix :
5 10 15
20 25 30
35 40 45
Enter the elements of second matrix :
2 4 6
8 10 12
14 16 18
The resultant matrix is :
3 6 9
12 15 18
21 24 27
-
UpdatedDec 31, 2019
-
Views4,370
You May Like
Program to maintain employee details using structures
Program to maintain student details using structures
Check whether the person is eligible to vote or not
Print the numbers that are divisible by a given no.
Program to generate magic square
To sort the given numbers in ascending & descending order