It should sum elements of the array of x from 135.1 to 24.1 and the output be 594.4
but the output is 570.3 which is the sum from 135.1 to 24.6 not 24.1
it works as the if condition is sum + x[i] smaller than 594.4 only and ignores the equal condition.
am very confused about it.
1 2 3 4 5 6
double x[12] = {135.1,73.1,63.2,59.1,59.1,53.1,36.1,35.1,31.8,24.6,24.1,50.2};
double sum = 0;
for (int i = 0; i < 12; i++)
if (sum + x[i] <= 594.4)
sum += x[i];
cout << sum << endl;