How to fix?
In theory, all right, I do not understand what is wrong.

Mistake

  • 3
    the compiler doubts that the value of res is likely to be assigned. You will have to initialize the variable - assign it any value, for example 0. - 4per

1 answer 1

It is necessary in any case to initialize the variable before the first use for reading. For example:

double res = 0; 

The problem is that in your code, the loop can never be executed. If the length of the arrays is zero, then the variable will not be initialized.