Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.83 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <math.h>
  4.  
  5. float series(float x, float eps){
  6.     int n = 1;
  7.     float sum = 0, k;
  8.     k = 1 / (3 * x);
  9.  
  10.     while (fabs(k) > eps) {
  11.         if (x == 0) {
  12.             return sum;
  13.         }
  14.  
  15.         sum =+ k;
  16.         k = k * ((2 * n - 3)) / ((2 * n * (2 * n + 1) * x));
  17.         n++;
  18.     }
  19.  
  20.     return sum;
  21. }
  22.  
  23. int main()
  24.  
  25. {
  26.     float A, B;
  27.     float r;
  28.     float eps;
  29.     float x, Fx;
  30.  
  31.     printf("\t Input initial value interval A= ");
  32.     scanf("%f", &A);
  33.  
  34.     printf("\n\t Input initial value interval B= ");
  35.     scanf("%f", &B);
  36.  
  37.     while (B <= A) {
  38.     printf("\nInitial value of limit (A) have to be less final value (B)");
  39.  
  40.     printf("\n\t Input initial value interval A= ");
  41.     scanf("%f", &A);
  42.  
  43.     printf("\n\t Input initial value interval B= ");
  44.     scanf("%f", &B);
  45.     }
  46.  
  47.     printf("\n\t Input step r= ");
  48.     scanf("%f", &r);
  49.  
  50.     while (r <= 0 || r >= (B - A)) {
  51.         printf("\n Step tabulation have to be more than zero and less interval from A to B(%.f)\n",fabs(B - A));
  52.         printf("\n\t Input initial value step r= ");
  53.         scanf("%f",&r);
  54.     }
  55.  
  56.     printf("\n\t Input accesable infelicity eps= ");
  57.     scanf("%f", &eps);
  58.  
  59.     while ((eps >= 1) || (eps <= 0)) {
  60.         printf("\n\t Accesable infelicity (eps) have to be more than zero and less than unit");
  61.           printf("\n\t Input initial value eps= ");
  62.         scanf("%f",&eps);
  63.     }
  64.  
  65.     printf("\n\t\t\t    Table"
  66.            "\n\t\t+---------+------------------+"
  67.            "\n\t\t|    X    |        F(X)      |"
  68.            "\n\t\t+---------+------------------+");
  69.      x = A;
  70.     while (x <= B) {
  71.         Fx = series(x, eps);
  72.         printf("\n\t\t|  %5.2f  |     %7.4f      |",x , Fx);
  73.         x=x+r;
  74.     }
  75.     printf("\n\t\t+---------+------------------+");
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement