When both sides of / are integers, C throws the fractional part away: 7 / 2 is 3. The remainder operator % gives what is left over: 7 % 2 is 1. To keep the fraction, make one side a double before dividing: (double)7 / 2 is 3.5. Casting after the division is too late, because the fraction is already gone.
An int holds values up to 2,147,483,647. A result past that overflows, which C treats as undefined behavior: a real build may print a nonsense number. In this workspace the program stops and names the line. When a total can be large, such as cents across many shares, compute it in long long, which holds values past nine quintillion.
Integer division, remainder, a division that keeps the fraction, and a product too large for int.