why are the results at the end different when a is 0? when i type in a=1 and b=10 both results are 38.5 but when i type in a=0 and b=10 i get 32 and 39.5.
int a, b;
cin >> a >> b;
int sum1 = 0, sum2 = 0;
for (int i = a; i <= b; i++)
{
sum1 = sum1 + pow(i, 2);
}
int n = b - a + 1;
cout << float(sum1) / n << endl;
if (a == 0)cout << float(sum1) / b + 1 << endl;
else cout << float(sum1) / b << endl;