# Thread: Fractions are just = to 0

1. ## Fractions are just = to 0

I have made a program to multiply matrixs together. However when I try to put a fraction as one of the values of a matrix it equals to zero. Here is my program any help will be much appreciated.

Code:
```#include <stdio.h>
#include <math.h>

int main()

{

#define k 3
#define m 5
#define n 4
int i,j,l;

float A[k][m] = { {2,-1/3,0,2/3,4},
{1/2,3/2,4,-2,1},
{0,3,-9/7,6/7,4/3},
};

float B[m][n] = { {6/5,0,-2,1/3},
{5,7/2,3/4,-3/2},
{0,-1,1,0},
{9/2,3/7,-3,3},
{4,-1/2,0,3/4},
};

float C[k][n] = { {0,0,0,0},
{0,0,0,0},
{0,0,0,0},
};

for(i = 0 ; i < k ; i++)
{
for(j = 0 ; j < n ; j++)
{
for(l = 0 ; l < m ; l++)
{
C[i][j] += A[i][l]*B[l][j];
}
}
}

printf("      A \n------------\n");

for(i = 0 ; i < k ; i++)
{
for(j = 0 ; j < m ; j++)
{
printf("%.0f  ", A[i][j]);
}
printf("\n");
}

printf("\n");
printf("      B \n------------\n");

for(i = 0 ; i < k ; i++)
{
for(j = 0 ; j < m ; j++)
{
printf("%.0f   ", B[i][j]);
}
printf("\n");
}

printf("\n");
printf("      C \n------------\n");

for(i = 0 ; i < k ; i++)
{
for(j = 0 ; j < m ; j++)
{
printf("%f  ", C[i][j]);
}
printf("\n");
}

printf("\n");

}```
this is what comes out
A
------------
2 0 0 0 4
0 1 4 -2 1
0 3 -1 0 1

B
------------
1 0 -2 0 5
5 3 0 -1 0
0 -1 1 0 4

C
------------
18 0 -4 0 1
1 -1 10 -7 19
19 10 -1 -3 1

2. Your fractions turn out to be zero because you're dealing with integers and integer division. You have to use float literals or double literals for this to work.