Hello evey body I nedd to heple me to multiply 2 matrix in C=A*B A --->16*16 B -
ID: 3640008 • Letter: H
Question
Hello evey body I nedd to heple me to multiply 2 matrix in
C=A*B
A --->16*16
B ----> 16*6
C ----->16*16
The value of each element in Matrix A is 1
The value of each element in Matrix B is 10
show me the output C product on the screen without asking usere to inter anything from command line.
A= 1 1 1 1 1 1 1 -------- B= 10 10 10 10 ----- c =
==========================================
what I did is
int main()
{
int m, n, p, q, c, d, k, sum = 0;
int first[15][15], second[15][15], multiply[15][15];
for ( c = 0 ; c <=15 ; c++ )
for ( d = 0 ; d <=15 ; d++ )
for ( c = 0 ; c <=15 ; c++ )
for ( d = 0 ; d <=15 ; d++ )
for ( c = 0 ; c <=15 ; c++ )
{
for ( d = 0 ; d <=15 ; d++ )
{
for ( k = 0 ; k <=15 ; k++ )
{
sum = sum + first[c][k]*second[k][d];
}
multiply[c][d] = sum;
sum = 0;
}
}
for ( c = 0 ; c <=15; c++ )
{
for ( d = 0 ; d <=15; d++ )
// printf(" ");
}
return 0;
}
=====================
nedd to see the oout put in 2d diminsition
Thanks alot
Explanation / Answer
#include "stdio.h"
int main()
{
int m, n, p, q, c, d, k, sum = 0;
int first[16][16], second[16][16], multiply[16][16];
for ( c = 0 ; c <=15 ; c++ )
{
for ( d = 0 ; d <=15 ; d++ )
{
first[c][d] = 1;
second[c][d] = 10;
}
}
for ( c = 0 ; c <=15 ; c++ )
{
for ( d = 0 ; d <=15 ; d++ )
{
sum = 0;
for ( k = 0 ; k <=15 ; k++ )
{
sum = sum + first[c][k]*second[k][d];
}
multiply[c][d] = sum;
}
}
printf(" Matrix A is: ");
for ( c = 0 ; c <=15; c++ )
{
for ( d = 0 ; d <=15; d++ )
printf("%d ", first[c][d]);
printf(" ");
}
printf(" Matrix B is: ");
for ( c = 0 ; c <=15; c++ )
{
for ( d = 0 ; d <=15; d++ )
printf("%d ", second[c][d]);
printf(" ");
}
printf(" Result Matrix is: ");
for ( c = 0 ; c <=15; c++ )
{
for ( d = 0 ; d <=15; d++ )
printf("%d ", multiply[c][d]);
printf(" ");
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.