I'm using two different variable to divide in the calculation with the variable from int
and double
. These work fine when I use something like:
int cost
cost = 40;
cost = (cost / 400) * 20 * 2;
For this the method works fine and I get the right result which is 4
, but when I use the variable cost
and put it in the header instead, like:
#define cost 40
int total_cost;
total_cost = (cost / 400) * 20 * 2;
this always results in 0
for me and I don't know why. Even if I use printf
with %d
or %f
this still gives me a result of 0
.