# Program to find sum, subtraction, multiplication & transpose of matrices.

Program to find sum, subtraction, multiplication & transpose of matrices.

answered Jan 9 by (140 points)
#Create a list of lists for both variables x and y
X = [[12,7,3],
[4 ,5,6],
[7 ,8,9]]

Y = [[5,8,1],
[6,7,3],
[4,5,9]]

#Defining a variable called result

result = [[0,0,0],
[0,0,0],
[0,0,0]]

# iterate through rows
for i in range(len(X)):
# iterate through columns
for j in range(len(X)):
result[i][j] = X[i][j] + Y[i][j]

for r in result:
print(r)
commented Jan 14
create a one program..not a one by one programs
answered Jan 9 by (240 points)

But you need to say in which language you want to...

I am learning C++ and here is the code:

int findSum(int x, int y) {

return x + y;

}

int findSubtraction(int x, int y) {

return x - y;

}

int findMultiplication(int x, int y) {

return x * y;

}

I don't know what the transpose of matrices is.

+1 vote
For C language:

#include <stdio.h>

#include <conio.h>

void main()

{

int a,b;

printf("enter the first number: ");

scanf("%d",&a);

printf("enter the second number: ");

scanf("%d",&b);

int c=a+b;

printf("the sum of two numbers is: %d",c);

getch();

}

Similarly for the place of subtraction and multiplication, just use c=a-b and c=a*b respectively

Also in the last printf mention the difference of the two numbers is and the product of the two numbers is respectively.
commented Jan 11 by (120 points)
you didnt declare c