Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <tgmath.h>
- int main()
- {
- int i = 1;
- printf("Enter the x: ");
- float x,e;
- scanf("%f",&x);
- printf("Enter the ะต: ");
- scanf("%f",&e);
- float n = 1./pow(x,i);
- float npr=0;
- int index;
- float no = 0;
- while(n-npr>=e){
- printf("%f\n",n);
- npr = n;
- if(n-npr<=e){
- index = i;
- no = n;
- }
- i++;
- n = 1./pow(x,i);
- }
- if (no==0){
- index = i;
- no = n;
- }
- printf("Index : %f", index);
- printf("N : %f",no);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement