Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <conio.h>
  4. #include <math.h>
  5. using namespace std;
  6.  
  7. int _tmain(int argc, _TCHAR* argv[])
  8. {
  9. float suma, czescskladowa, wyrazenie;
  10. int x, n, i;
  11. cout << "Podaj wspolczynnik n w celu obliczenia ciagu 1/x + 1/x^2 + 1/x^3 + 1/x^4 + . . . + 1/x^n" << endl;
  12. cin >> n;
  13. cout << endl << "Podaj wartosc x" << endl;
  14. cin >> x;
  15. suma = 0;
  16. for (i = 1; i <= n; i++)
  17. {
  18. wyrazenie = 1/ x;
  19. czescskladowa = pow(wyrazenie, i);
  20. suma = suma + czescskladowa;
  21. }
  22. cout << endl << "suma to " << suma << endl;
  23. system("pause");
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement