//Write a C++ program to determine and print the sum of the series ( 1/6 + 1/10 + 1/14 + … + 1/(2*(2*n+1)) )for a given value of n. The value of n should be given interactively through the terminal. (Note: You will only get credit if you use a loop!)
so i have to find the sum and i have tried it for a while and i cant get it. im using this code and it works good if the series was (6+10+14+...+(2*(2*n+1)) ), but as soon as i try to put "1/(2*(2*n+1)) " i get a zero as the answer. i know its something simple since we are not that advanced in class but i still cant find it. thank you very much for any help.
#include <iostream>
#include <cmath>
using namespace std;
int main( void )
{
int iCount = 0, iMax = 0;
float iAns = 0;
cout << "Enter a positive integer for n:" << endl;
cin >> iMax;
for( iCount=1; iCount <= iMax; iCount++ )
{
iAns = iAns + 2*((iCount*2)+1) ; // the 2*((iCount*2)+1) works if the series was (6+10+14+...), and as soon as i put a 1/ in front of it instead of giving me the right answer it gives me 0.
}
cout << "The sum of this series is: " << iAns << endl;
return 1;
}