Kostiggig

Untitled

Nov 15th, 2022
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. void task2() {
  2.     double e;
  3.     int i = 1, x;
  4.     int powerX = 1, power = 2;
  5.     int fact = 1;
  6.     double currentValueOfF = 0, sum = 0;
  7.  
  8.     printOnNewLine("Введите x: ");
  9.     scanf("%d", &x);
  10.     printOnNewLine("Введите e: ");
  11.     scanf("%lf", &e);
  12.    
  13.     do
  14.     {
  15.         double divider = (cos(fact)) * i;
  16.         if(divider != 0) {
  17.             currentValueOfF = power / divider;
  18.             sum += currentValueOfF;
  19.         }
  20.  
  21.         fact *= i;
  22.         printf("i is %d", i);
  23.         powerX *= x;
  24.         power = calculatePower(2, powerX);
  25.         i++;
  26.     } while (currentValueOfF > e);
  27.    
  28.     printf("approximate sum is %lf", sum);
  29. }
Add Comment
Please, Sign In to add comment