(double)rezultat /= ...
not very good. The result of a cast expression is always rvalue, i. e. that which cannot be assigned. Related: you cannot change the type of expression (you can use it, but it will not change its type, just temporarily act as another type). After you have declared your variable as, say, int , you cannot save a double in it - however, you divided the division, etc., In the end, it will always be truncated.
You will most likely have to enter a temporary double variable to store the division result.
user529758
source share