fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n;
  7. cout << "n="; cin >> n;
  8.  
  9. double*a = new double[n], sum_n=0.;
  10.  
  11. cout << "Enter " << n << " elements:\n";
  12. for (int i = 0; i < n; i++)
  13. {
  14. cin >> a[i];
  15. if (a[i]<0.) sum_n+=a[i];
  16. }
  17.  
  18. cout << "sum negative = " << sum_n << "\n";
  19.  
  20. delete[]a;
  21. system("pause");
  22. return 0;
  23. }
Success #stdin #stdout #stderr 0s 4484KB
stdin
Standard input is empty
stdout
n=Enter 11037 elements:
sum negative = 0
stderr
sh: 1: pause: not found