Hi, I wonder why this program works the way it does. it took some time to figure what was going on but when i did i could not really explain why.
Code:
int fruits = 45; /* Amount of Fruits I have to sell */
int buyers = 7; /* Number of buyers */
int amount_per_buyer = 45 / 7;
printf("Each buyer bought %d amount of fruits.\n\n", amount_per_buyer);
return(0);
The problems is within the division 45 / 7 returns 6 with a remainder of i guess 4 from my calculator. But it never prompts you that there was a remainder. I guess this could lead to a bug in a banking application.
Please kindly put me right. Thanks