guyzzzz please help me!..

closed account (3C7iz8AR)
Write a MAIN function and a FUNCTION to compute the sum of the below series.
1 + 2!/4 + 3!/27 + 4!/256 + ...n!/(n^n)
Determine the general term of the series first.

Within the MAIN function:
• In a while(1) loop: (it causes a permanent loop (a loop that executes for ever).
Read a variable EPSILON of type DOUBLE (desired accuracy) from the standard input.

EPSILON is an extremely small positive number which can be anything between
1E-06 (10^(-6)) and 1E-15 (10^(-15)).

• Program should terminate when zero value is entered for the EPSILON.
• EPSILON value will be passed to the FUNCTION as an argument.

Within the FUNCTION:
• . In a do-while loop:
• . Continue adding up the terms until |Sn+1 - Sn| < EPSILON.
• . Sn is the sum of the first n-terms.
• . Sn+1 is the sum of the first (n+1)-terms.
• When the desired accuracy EPSILON is reached print the SUM and the number of TERMS added to the sum.

TEST the program with different EPSILON values between 1E-06 and 1E-15.
Have you tried turning it off and on again?
closed account (3C7iz8AR)
i have no clue :(
closed account (3C7iz8AR)
anyone to help??
closed account (3C7iz8AR)
urgent!...
you need a loop like so:
1
2
3
4
5
double value = 1;
for(int i = 2; ...; i++)
{
  value += fact(i) / (i * i);
}
closed account (3C7iz8AR)
it says that use a do-while loop and a while(1) loop
This will get you started.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void SumSequence(const double eps)
{
    //use a do-while loop to figure out the sum sequence
    //print results
}

int main()
{
    while(1)
    {
        double epsilon = 0.0;
        //get epsilon from user
        SumSequence(epsilon);
     }
    return 0;
}
Last edited on
closed account (3C7iz8AR)
thnks
can you write the codes exactly?
We're not going to do your homework for you. We're happy to help you get started, and if you have some code with problems in, we'll help you work out what they are.

Have a go at it. When you get stuck, and have some specific questions, come back to us.
Yes, I managed to do it in about 15 minutes. However, board policy is not to give away homework solutions. The code I provided should compile as is. You may take that and begin adding to it to solve your problem. If you encounter specific problems as you implement your solution, you should ask about those specific problems.
Topic archived. No new replies allowed.