- Related Questions & Answers
- C Program for Tower of Hanoi
- C++ Program for Dijkstra’s shortest path algorithm?
- C/C++ Program for nth Catalan Number?
- C Program to Multiply two Floating Point Numbers?
- C program to find the length of a string?
- C Program to Check if all digits of a number divide it
- C Program to Check if a Given String is a Palindrome?
- Write a program to Delete a Tree in C programming
- Write a C program to print “ Tutorials Point ” without using a semicolon
- Sum of the nodes of a Singly Linked List in C Program
- Sum of first n natural numbers in C Program
- C Program for simple interest?
- Area of a n-sided regular polygon with given Radius in C Program?
- Area of a leaf inside a square in C Program?
- C Program for Area of a square inscribed in a circle which is inscribed in a hexagon?

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In this article, we will learn about the solution to the problem statement given below.

**Problem statement **− We are given two matrices, we need to multiply them and print the result.

For two matrices to be multiplied columns of the first matrix must be identical to that of the rows of the second matrix

Each time this condition is evaluated to be true computation is performed

Now let’s observe the concept in the implementation below−

A = [[1, 2, 3], [4, 5, 6], [7, 8, 9] ] B = [[5, 3, 3], [6, 5, 4], [0, 2, 0] ] result= [[0, 0, 0], [0, 0, 0], [0, 0, 0] ] # iterating by row for i in range(len(A)): # iterating by column for j in range(len(B[0])): # iterating by rows for k in range(len(B)): result[i][j] += A[i][k] * B[k][j] for ele in result: print(ele)

[17, 19, 11] [50, 49, 32] [83, 79, 53]

A = [[1, 2, 3], [4, 5, 6], [7, 8, 9] ] B = [[5, 3, 3], [6, 5, 4], [0, 2, 0] ] # using built-in zip function result = [[sum(a * b for a, b in zip(A_row, B_col)) for B_col in zip(*B)] for A_row in A] for ele in result: print(ele)

[17, 19, 11] [50, 49, 32] [83, 79, 53]

In this article, we have learned how to multiply two matrices.

Advertisements