2D Array Matrix Multiplication 1
2D Array Matrix Multiplication 1
Multiplication
Two-Dimensional (2D) Arrays in C
Where ,
#include<stdio.h>
int main ( ) {
output :
int arr [3] [2] = { { 0 , 1 } , { 2 , 3} , { 4 , 5 } } ; arr [ 0 ] [ 0 ] : 0
for ( int i = 0 ; i < 3 ; i++) { arr [ 0 ] [ 1 ] : 1
for ( int j = 0 ; j < 2 ; j++) { arr [ 2 ] [ 0 ] : 2
printf (“arr[ %d] [%d] : %d “, i , j , arr [ i ] [ j ] ) ; arr [ 1 ] [ 1 ] : 3
} arr [ 2 ] [ 0 ] : 4
printf (“\n”) ; arr [ 2 ] [ 1 ] : 5
MATRIX
MULTIPLICATION
Matrix Multiplication in C
A matrix is a collection of numbers
o rg a n i z e d i n ro w s a n d c o l u m n s ,
re p re s e n t e d b y a t w o - d i m e n s i o n a l
a rr a y i n C . M a t r i c e s c a n e i t h e r b e
s q u a re o r re c t a n g u l a r. I n t h i s
a r t i c l e , w e w i l l l e a rn t h e
multiplication of two matrices in
t h e C p ro g r a m m i n g l a n g u a g e .
Example :
Input :
mat[ ] [ ] = { { 1 , 2 },
{3,4}}
mat[ ] [ ] = { { 5 , 6 }
{7,8}
int main() {
int i, j, k;
scanf("%d", &A[i][j]);
C[i][j]=0; Matrix A : 1 2
C [ i ] [ j ] += A [ i ] [ k ] * B [ k ] [ j ] ; Matrix B : 5 6
} 7 8