Harmonic Sum

Ok so I've got it so it shows what the number being added will be at each N (as in at N=6 it will be 1+1/2+1/3+1/4+1/5+1/6) however I can't get it to add them up.

int main()
{
float Harmonic_Sum;
int N;
char tryagain;


do{
Harmonic_Sum = 0;
cout << "How many terms are in the series?" ;
cin >> N;

for(int i=1; i<= N; i++){
Harmonic_Sum = 1.0/i;
cout << "i= "<< i << " sum= " <<Harmonic_Sum<< endl;
}
cout << "Series sum is " << [DONT KNOW WHAT TO PUT HERE] << endl;


cout << "\n Try again?";
cin>> tryagain;

cin.ignore(80,'\n');

}while(tryagain == 'y' || tryagain == 'Y');



Nevermind I fixed it haha
Last edited on
You'll need to make a variable that keeps track of the sum and print that.
Topic archived. No new replies allowed.