(A) Let the number of John's marbles be $x$.
Therefore,the number of Jivanti's marbles $= 45 - x$.
After losing $5$ marbles each:
Number of John's marbles $= x - 5$.
Number of Jivanti's marbles $= 45 - x - 5 = 40 - x$.
It is given that the product of their remaining marbles is $124$.
So,$(x - 5)(40 - x) = 124$.
Expanding the equation: $40x - x^2 - 200 + 5x = 124$.
Rearranging terms: $-x^2 + 45x - 200 = 124$.
$x^2 - 45x + 324 = 0$.
Factoring the quadratic equation: $x^2 - 36x - 9x + 324 = 0$.
$x(x - 36) - 9(x - 36) = 0$.
$(x - 36)(x - 9) = 0$.
Thus,$x = 36$ or $x = 9$.
If John had $36$ marbles,Jivanti had $45 - 36 = 9$ marbles.
If John had $9$ marbles,Jivanti had $45 - 9 = 36$ marbles.