#include
void main()
{
int a[3][3],b[3][3],c[3][3],i,j;
printf("Enter the First 3x3 Matrix : ");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
scanf("%d",&a[i][j]);
}
printf("Enter the Second 3x3 Matrix : ");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
scanf("%d",&b[i][j]);
}
printf("\nThe Sum of Matrices is : ");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=a[i][j]+b[i][j];
printf("%d ",&c[i][j];
}
printf("\n");
}
printf("\n\nThe Difference of Matrices is : ");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=a[i][j]-b[i][j];
printf("%d ",&c[i][j];
}
printf("\n");
}
}
if u want to add or sub greater dimension matrices
declare a,b,c with [10][10]
declare two variable r for rows and c for columns
accept r and c
and in the i for loop replace 3 by r
and in the j for loop replace 3 by c
2006-07-05 22:08:52
·
answer #1
·
answered by Aashish 2
·
0⤊
0⤋
I could probably do it in C++, which is the same as C. All you have to do is enter 18 variables: A1, A2, ... , A9, B1, B2, ... , B9.
Then calculate A1+B1, A2+B2, etc, and print out the results.
It would be fairly simple to print out both add and subtract. I don't think that I am good enough to give the option of adding OR subtracting!
2006-07-05 22:05:16
·
answer #2
·
answered by powhound 7
·
0⤊
0⤋
Sounds like Coursework lol
2006-07-05 22:02:10
·
answer #3
·
answered by the_dt 4
·
0⤊
0⤋
int m=3; int n=3;
int i,j;
int a[m][n], b[m][n],c[m][n],d[m][n];
for (i=0;i<3;i++){
for (j=0;j<3;j++){
cout << "enter row elements one at a time :"
cin >> a[i][j] ;
}}
cout << "Enter the elements of the second matrix by row " << endl;
for (i=0;i<3;i++){
for (j=0;j<3;j++){
cout << "enter row elements one at a time :"
cin >> b[i][j] ;
}}
for (i=0;i<3;i++){
for (j=0;j<3;j++){
c[i][j]=a[i][j]+b[i][j];
d[i][j]=a[i][j]-b[i][j];
}
}
cout << "output the elements of the matrix for sum " <
for (i=0;i<3;i++){
for (j=0;j<3;j++){
cout << c[i][j] ;
}
endl;
}
cout << "output the elements of the matrix for sum " <
for (i=0;i<3;i++){
for (j=0;j<3;j++){
cout << d[i][j] ;
}
endl;
}
Sorry I have no time to complete
2006-07-05 22:09:44
·
answer #4
·
answered by iyiogrenci 6
·
0⤊
0⤋
send me your email if this is an urgent assignment.
2016-03-27 05:55:14
·
answer #5
·
answered by Anonymous
·
0⤊
0⤋