Advertisement
evgenko

Untitled

Dec 13th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <tgmath.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.         if(n-npr<=e){
  21.             index = i;
  22.             no = n;
  23.         }
  24.         i++;
  25.         n = 1./pow(x,i);
  26.     }
  27.     if (no==0){
  28.         index = i;
  29.         no = n;
  30.     }
  31.     printf("Index : %f", index);
  32.     printf("N : %f",no);
  33.     return 0;
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement