#include "stdafx.h"
#include "math.h"
#include "stdio.h"
int i, res, fact;
long double x, e, expect, err, eps;
void main()
{
printf("enter eps: ");
scanf("%lf", &eps);
printf("\n");
int k;
/*
for (k = 1; k < 7; k++)
{
printf("x = ");
scanf("%lf", &x);
err = exp(x);
e = 1;
fact = 1;
i = 1;
while (err>eps)
{
fact = fact*i;
e = e + pow(x, i) / fact;
expect = exp(x);
err = fabs(expect - e);
i++;
}
printf("\n =======RESULTS =======\n e(%.l0f) = %lf was expected \n", x, expect);
printf("e(%.0f) = %lf found \n", x, e);
printf("for err < %.lf n = %i", eps, i);
printf("\n");
}
*/
printf("x = ;");
scanf("%lf", &x);
int n;
printf(" n = \n");
scanf("%i", &n);
for (i = 1; i < n+1; i++)
{
fact = fact*i;
e = e + pow(x, i) / fact;
expect = exp(x);
err = fabs(expect - e);
i++;
}
scanf("%i", &i);
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.