Advertisement
evgenko

Untitled

Dec 17th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4.  
  5. int main()
  6. {
  7.     int i = 1;
  8.     printf("Enter the x: ");
  9.     float x,e;
  10.     scanf("%f",&x);
  11.     printf("Enter the ะต: ");
  12.     scanf("%f",&e);
  13.     float n = 1./ pow(x,i);
  14.     float npr=0;
  15.     int index;
  16.     float no = 0;
  17.     while(n-npr>=e){
  18.         printf("%f\n",n);
  19.         npr = n;
  20.         i++;
  21.         n = 1./pow(x,i);
  22.     }
  23.     i=2;
  24.     npr = 1./pow(x,1);
  25.     n = 1./pow(x,i);
  26.     while (npr-n>=e){
  27.         i++;
  28.         npr=n;
  29.         n=1./pow(x,i);
  30.     }
  31.     printf("Index : %d", i);
  32.     printf("n : %f",n);
  33.     return 0;
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement