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.
cost(or perhaps the 400) should be adouble, or the formula simplified or operations rearranged. For example,(cost / 400) * 20 * 2==(cost / 400) * 40==cost * 40 / 400==cost / 10, unless you intend to rely on integer division. (Doesn't seem to be the case, considering how much trouble it's giving you.)