logo

Množenje matrica u C-u

Množenje matrice u C: Možemo zbrajati, oduzimati, množiti i dijeliti 2 matrice. Da bismo to učinili, od korisnika unosimo podatke o broju retka, broju stupca, prvim elementima matrice i drugim elementima matrice. Zatim vršimo množenje na matricama koje je unio korisnik.

niz u c++

U množenju matrica prva matrica jedan element retka se množi sa drugom matricom svi elementi stupca .

Pokušajmo razumjeti množenje matrice 2*2 i 3*3 matrice prema donjoj slici:

arraylist metode
program za množenje matrica u c

Pogledajmo program množenja matrica u C-u.

 #include #include int main(){ int a[10][10],b[10][10],mul[10][10],r,c,i,j,k; system('cls'); printf('enter the number of row='); scanf('%d',&r); printf('enter the number of column='); scanf('%d',&c); printf('enter the first matrix element=
&apos;); for(i=0;i<r;i++) { for(j="0;j&lt;c;j++)" scanf('%d',&a[i][j]); } printf('enter the second matrix element="
&apos;);" for(i="0;i&lt;r;i++)" scanf('%d',&b[i][j]); printf('multiply of mul[i][j]="0;" for(k="0;k&lt;c;k++)" mul[i][j]+="a[i][k]*b[k][j];" for printing result printf('%d	',mul[i][j]); printf('
'); return 0; < pre> <p> <strong>Output:</strong> </p> <pre> enter the number of row=3 enter the number of column=3 enter the first matrix element= 1 1 1 2 2 2 3 3 3 enter the second matrix element= 1 1 1 2 2 2 3 3 3 multiply of the matrix= 6 6 6 12 12 12 18 18 18 </pre> <p>Let&apos;s try to understand the matrix multiplication of <strong>3*3 and 3*3</strong> matrices by the figure given below:</p> <img src="//techcodeview.com/img/c-programs/01/matrix-multiplication-c-2.webp" alt="matrix multiplication in c"> <hr></r;i++)>

Pokušajmo razumjeti množenje matrice 3*3 i 3*3 matrice prema donjoj slici:

množenje matrice u c