0% found this document useful (0 votes)
18 views1 page

Multi Matrix

The document contains a C program that initializes two matrices A and B based on user-defined dimensions. It populates these matrices with the sum of their indices and attempts to compute a third matrix C, which is intended to hold the product of A and B. However, the multiplication logic is incorrect as it uses the same indices for both matrices instead of the appropriate matrix multiplication algorithm.

Uploaded by

Anjali Shakya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views1 page

Multi Matrix

The document contains a C program that initializes two matrices A and B based on user-defined dimensions. It populates these matrices with the sum of their indices and attempts to compute a third matrix C, which is intended to hold the product of A and B. However, the multiplication logic is incorrect as it uses the same indices for both matrices instead of the appropriate matrix multiplication algorithm.

Uploaded by

Anjali Shakya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#include<stdio.

h>
int main(){
int A[30][30], B[30][30], C[30][30], i, j, k, r, c;
printf("please enter the no. of rows:");
scanf("%d", &r);
printf("please enter the no. of column:");
scanf("%d", &c);

for(i=0; i<r; i++)


for(j=0; j<c; j++){
A[i][j]= i+j;
printf("%d\t", A[i][j]);
if(j==c-1){
printf("\n\n");
}
}
printf("\n");
for(i=0; i<r; i++)
for(j=0; j<c; j++){
B[i][j]= i+j;
printf("%d\t", B[i][j]);
if(j==c-1){
printf("\n\n");
}
}
printf("\n");
for(i=0; i<r; i++)
for(j=0; j<c; j++){
C[i][j]=0;
for(k=0; k<r; k++){
C[i][j]= C[i][j] + A[i][j]*B[i][j];
}
printf("%d\t", C[i][j]);
if(j==c-1){
printf("\n\n");
}
}
return 0;
}

You might also like