Advertisement
Mary_99

ex2.5b

Nov 25th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5.  
  6. int main()
  7. {
  8. int n=1;
  9. float e;
  10. printf ("enter any positive number e=\n");
  11. scanf("%f", &e);
  12.  
  13. float sum=0;
  14.  
  15.  
  16.      do{
  17.  
  18.       sum=sum+1.0/n;
  19.      n++;
  20.  
  21.      }while(sum<e);
  22.  
  23.      printf("%d\n",n);
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement