### Don't Know where to begin

Hey, Im new to this forum but my tutor recomended I check this website out. I was just wondering if anyone could give me guidance on my current project. I have no idea where to start or what the goal is, I am completely LOST. My tutor didn't even know what this project is asking me to do, so I was hoping someone here could kinda just help me figure out the layout of the program (the steps I'll need to take)

Here's the Project:
The mathematical value e can be computed by summing the series: S1n/i ! where the sum is over the integers i in{0,1,2,3,….} Note: 0! Is defined to be 1, so the first term in the series is 1 (and so is the second). Compute e by summing 6 terms, 10 terms and 20 terms in the series. You will need to use a double value to hold your counter i, your sum and product variables. Output each of your approximations. Display the error in each approximation. Absolute_error = fabs(e-approximation) and relative_error = fabs(e-approximation)/e. Note that the abs() function in C uses an int argument and returns an int result, which is not sufficiently precise for our problem, so you must use fabs(). The correct value of e can be determined to full double precision using the exponential function exp() defined in the math.h file: exp(1) computes e1 to full machine precision.

Aside: We have not covered ANSI C output mechanism of printf. printf required a “format string” to indicate the datatypes to output and how many digits to allocate. To use it to print a real value you must provide %f (float) or %lf long float formatting. %d is used for integers.

If you use printf() for your results, you can get many decimal places of output with a format like
printf("e is %20.17lf approximation using 20 terms is %20.17lf",e,sum);
How familiar are you with c++? Do you know what a "for" loop is?

This sounds stupid bits what he is asking you to do.

As far as where to start I would say this:

 ``1234567`` ``````int main() { return 0; }``````
yeah i have a basic understanding of C++, and the for loop we just started today in class. I do know about int main and the return 0; and i know ill need to put #include <math.h>

I guess what I'm looking for is the steps that the program will need to do inorder to complete this project. Kinda put the project in "simple English" more like a step-by-step guide or a recipe type set up. Then from there I can probably figure out the Code that will be needed.

By the way, I'm using Eclipse
If you read the project description it says that you will summing values. The 'for' loop is perfect for that.

"Note: 0! Is defined to be 1, so the first term in the series is 1..."
"Compute e by summing 6 terms, 10 terms and 20 terms in the series."

You have three loops here, and the instruction tell you what the first value is.
so do I want to set the counter i to 1?
omg:

 ``1234567891011`` ``````int number_to_add_to, sum = 0; //i would write a prompt function to set number_to_add_to for((int, float, double, etc...) x = 0; x <= number_to_add_to; x++) { if(x == 0) { sum = (sum + 1); //because 0 is 1 continue; } sum = (sum + x); }``````

the easiest thing in the world.
Last edited on
Isn't it something different, though? This is a pretty advanced program. e is actually calculate by doing 1 + 1/1! + 1/2! + 1/3!...etc. You would need to learn how to do factorials in c++ (search recursion on google) and you would have to have a predefined (perhaps set by user?) accuracy value.
The code I posted can be used as framework. and e can be declared as a constant, and x can be casted as a float is declared as an integer.
Topic archived. No new replies allowed.