# multiplying matricies

• 09-17-2011
danieldcc
multiplying matricies
so I think everything is good in my code, except when i print I get a few funny numbers. I think because the numbers are too big to be integers. How do I effectively convert them to show up properly in the code?

Code:

```#include <stdio.h> #include "max_sizes_b.h" int main (void) {         int A[MAX_L][MAX_N], B[MAX_M][MAX_N], C[MAX_L][MAX_N], i, j, l, m, n; scanf("%d%d%d", &l, &m, &n); for (i = 0; i < l; i++)   for (j = 0; j < m; j++)     scanf("%d ", &A[i][j]); for (i = 0; i < m; i++)   for (j = 0; j < n; j++)     scanf("%d ", &B[i][j]);     sumofarrays(A, B, C, l, m, n); for (i = 0; i < n; ++i) {   for (j = 0; j < n; j++)     printf("%4d ", C[i][j]);     printf("\n"); } return 0; }```
Code:

```#include <stdio.h> #include "max_sizes_b.h" void sumofarrays(int A[][MAX_M], int B[][MAX_N], int C[][MAX_N], int l, int m, int n) {         int i, j, k; for (i = 0; i < l; ++i)   for (j = 0; j < m; ++j)     {                 C[i][j] = 0.0;                 for (k = 0; k < m; ++k)                 C[i][j] = C[i][j] + A[i][k] * B[k][j];         } }```
• 09-17-2011
danieldcc
no, wait, I think something is wrong with my code......let me work on it some more
• 09-17-2011
danieldcc
ok i think i got it. this is right? right?

Code:

```#include <stdio.h> #include "max_sizes_b.h" int main (void) {         int A[MAX_L][MAX_N], B[MAX_M][MAX_N], C[MAX_L][MAX_N], i, j, l, m, n; scanf("%d%d%d", &l, &m, &n); for (i = 0; i < l; i++)   for (j = 0; j < m; j++)     scanf("%d ", &A[i][j]); for (i = 0; i < m; i++)   for (j = 0; j < n; j++)     scanf("%d ", &B[i][j]);     sumofarrays(A, B, C, l, m, n); for (i = 0; i < l; ++i) {   for (j = 0; j < n; j++)     printf("%4d ", C[i][j]);     printf("\n"); } return 0; }```
Code:

```#include <stdio.h> #include "max_sizes_b.h" void sumofarrays(int A[][MAX_M], int B[][MAX_N], int C[][MAX_N], int l, int m, int n) {         int i, j, k; for (i = 0; i < l; ++i)   for (j = 0; j < n; ++j)     {                 C[i][j] = 0.0;                 for (k = 0; k < m; ++k)                 C[i][j] = C[i][j] + A[i][k] * B[k][j];         } }```