Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include<iostream>
  2. #include<math.h>
  3. using namespace std;
  4.  
  5. float suma(int, float);
  6.  
  7. int main() {
  8.  
  9. float x;
  10. int n;
  11.  
  12. cout << "Unesite realan broj" << endl;
  13. cin >> x;
  14. cout << "Unesite prirodan broj" << endl;
  15. cin >> n;
  16.  
  17.  
  18.  
  19. cout<<suma(n, x);
  20.  
  21.  
  22.  
  23. system("pause>0");
  24. return 0;
  25. }
  26.  
  27. float suma(int n, float x) {
  28. float broj = 0;
  29. float suma = 0;
  30.  
  31.  
  32. for (int i = 1; i <= n; i++) {
  33.  
  34. broj = pow(x, i);
  35.  
  36. suma = suma + cos(broj);
  37.  
  38. }
  39. return suma;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement