Access Millions of academic & study documents

Also I suggest that when you use a for loop, use i instead of n as i

Content type
User Generated
Showing Page:
1/2
Also I suggest that when you use a for-loop, use i instead
of n as in indices it will make cleaner code.
for all x.
Solution
#include <iostream>
#include <math.h>
using namespace std;
int factorial(int n) {
int fact = 1;
for (int counter = 1; counter <= n; counter++)
{
fact = fact * counter;
}
return fact;
}
double fooboo(double x) {
//e^x = 1+ x+x2/2!
double sum = 1;
for(int i = 1; i < 5; i++) {
sum += pow(x,i)/factorial(i);

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/2

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
Also I suggest that when you use a for -loop, use i instead of n as in indices it will make cleaner code. for all x. Solution #include #include using namespace std; int factorial(int n) { int fact = 1; for (int counter = 1; counter ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4