i do my homework.
but i cant write it in class ... please help:
using namespace std;
int counter =1;
cout<<"enter value of x :";
while(counter <= x)
cout<<"total = : "<<total;
Several different issues here. First, the important variables used in the calculation need to be of type double, not int.
Since this is the summation of an infinite series, we need some way to determine how many terms to include. One way is to ask the user to enter that value. The more terms we use, the more accurate result - but beyond a certain point the later terms become too small to make a difference.
And there is a logic error, only a single loop is required, to iterate through each of the terms of the series.