Well, you lost some important things along the way.
Above, these two lines are the entirety of the
for
loop:
11 12 13
|
for(m=0; m<99; m++)
E = m*2 - 1;
|
That's because you omitted the braces around the loop.
As to what you should do next , in all honesty I'd suggest practice with simple examples until you understand how your code works.
For example,let's say you want to find the sum of the numbers from 1 to 10.
1+2+3+4+5+6+7+8+9+10
The answer is 55.
But let's use a loop to do that.
1 2 3 4 5 6
|
int total = 0;
for (int i=1; i<=10; i++)
{
total = total + i;
}
cout << "total = " << total << endl;
|
So now you know how to find the total of a very simple series.
In the real question, there are two other things to consider. Firstly, the terms involve fractional values, not integers, so you should use type
double
for the calculations. Secondly, the sign of each term alternates between plus and minus. It's no use just putting +- in there. The usual way to do this is to have a variable called sign. Set its initial value to +1. Each time around the loop, do this,
sign = -sign;
And multiply each term in the series by this value.
Hope this helps.