This is the series I've to find the sum of (upto x terms which user inputs):
1/1 + 1/3 + 1/5 + 1/7 + ...
Here is the code I wrote :
int x;
cout << "How many terms (x) you want to add the series till?\n\n ";
cin >> x;
float m, answer=0.0;
for (int n=0; n<x; n++)
{
m=1/((2*n)+1);
answer=answer+m;
}
cout << " \n The answer is " << answer;
However, the answer always comes as 1 so what I might be doing wrong here?