HELP: Convergent Series

For an assignment I have to approximate the value of the series below by calculating the partial sum of the convergent series to a user inputted number of terms.

Refer to this image for detailed explanation of obstacles: https://i.imgur.com/CPQo2JL.png

I have the basic skeleton of the program but dont know how to go about proceeding with creating the program. Please give some pointers!! MUCH APPRECIATED. Thanks.

-------------------------------------------------------------

#include <iostream>
#include <cmath>

using namespace std;


void sum1(double&, unsigned int);
double sum2(unsigned int);
unsigned int getValidPositiveInteger();

int main()
{
// TODO Add messages for the user
unsigned int n1 = getValidPositiveInteger(),n2;
// TODO Add messages for the user, call sum1
n2 = getValidPositiveInteger();
// TODO Add messages for the user, call sum2

// TODO Compare and display results
return 0;
}

void sum1(double& sum, unsigned int n)
{
// TODO Estimate the series to n terms
}

double sum2(unsigned int n)
{
// TODO Estimate the series to n terms
}

// Get a valid integer from the user
unsigned int getValidPositiveInteger() {
int userInput;

cin >> userInput;

while (cin.fail() || userInput < 0) {
cin.clear();
cin.ignore();
cout << "Please enter a positive integer only\n";
cin >> userInput;
}

return userInput;
}
Last edited on
Topic archived. No new replies allowed.