Advertisement
PavluisBodya

Untitled

Oct 16th, 2019
83
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 <cmath>
  3. using namespace std;
  4. int main()
  5. {
  6. int n;
  7. int x;
  8. float mult=1;
  9. float sum=0;
  10.  
  11. cout << "Enter n:";
  12. cin >> n;
  13. cout << "Enter x:";
  14. cin >>x ;
  15. float* a = new float [n] ;
  16. for (int i = 0; i < n; ++i)
  17. {
  18. a[i] = (1 / (i + 1)) + sqrt(abs(x));
  19.  
  20. }
  21. for (int i = 1; i <= n; ++i)
  22. {
  23. sum += a[i];
  24. mult *= a[i];
  25.  
  26. }
  27. cout << "Sum:" << sum << endl;
  28. cout << "Mult:" << mult << endl;
  29.  
  30.  
  31. system("pause");
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement