Answer the question
In order to leave comments, you need to log in
Can you please write the product of the sums in C++?
xs how, wrote, but does not give the correct value
for (int i = 0; i <= n-1; i++)
{
for (int j = 1; j <= n; j++)
{
sum += (x - i + j) * (x - i + j) * (x - i + j);
}
y *= sum;
}
Answer the question
In order to leave comments, you need to log in
You need to initialize the accumulator variables before the loops: Before the loop over i, you need to assign y = 1. Before the loop over j, you need to assign sum = 0.
Otherwise, you accumulate the sum for all different i in sum. And y is generally unclear what value it has before multiplication.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question