# 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() ;
}
RUN 1 :
~~~~~~~
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
# 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() ;
}
RUN 1 :
~~~~~~~
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
No comments:
Post a Comment