Guest User

Untitled

a guest
Aug 10th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. double sum_of_30_terms()
  2. {
  3. int i, count=0;
  4. double sum=0.0;
  5.  
  6. for(i=1; count < 30; i *= 2)
  7. {
  8. count++;
  9. sum += 1.0 / i;
  10. }
  11.  
  12. return sum;
  13. }
  14.  
  15. int main()
  16. {
  17. cout << "Sum of 30 terms= " << sum_of_30_terms();
  18. return 0;
  19. }
Add Comment
Please, Sign In to add comment