Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <math.h>
- float series(float x, float eps){
- int n = 1;
- float sum = 0, k;
- k = 1 / (3 * x);
- while (fabs(k) > eps) {
- if (x == 0) {
- return sum;
- }
- sum =+ k;
- k = k * ((2 * n - 3)) / ((2 * n * (2 * n + 1) * x));
- n++;
- }
- return sum;
- }
- int main()
- {
- float A, B;
- float r;
- float eps;
- float x, Fx;
- printf("\t Input initial value interval A= ");
- scanf("%f", &A);
- printf("\n\t Input initial value interval B= ");
- scanf("%f", &B);
- while (B <= A) {
- printf("\nInitial value of limit (A) have to be less final value (B)");
- printf("\n\t Input initial value interval A= ");
- scanf("%f", &A);
- printf("\n\t Input initial value interval B= ");
- scanf("%f", &B);
- }
- printf("\n\t Input step r= ");
- scanf("%f", &r);
- while (r <= 0 || r >= (B - A)) {
- printf("\n Step tabulation have to be more than zero and less interval from A to B(%.f)\n",fabs(B - A));
- printf("\n\t Input initial value step r= ");
- scanf("%f",&r);
- }
- printf("\n\t Input accesable infelicity eps= ");
- scanf("%f", &eps);
- while ((eps >= 1) || (eps <= 0)) {
- printf("\n\t Accesable infelicity (eps) have to be more than zero and less than unit");
- printf("\n\t Input initial value eps= ");
- scanf("%f",&eps);
- }
- printf("\n\t\t\t Table"
- "\n\t\t+---------+------------------+"
- "\n\t\t| X | F(X) |"
- "\n\t\t+---------+------------------+");
- x = A;
- while (x <= B) {
- Fx = series(x, eps);
- printf("\n\t\t| %5.2f | %7.4f |",x , Fx);
- x=x+r;
- }
- printf("\n\t\t+---------+------------------+");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement