Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int compute_sum( int Element[], int i);
  6. int main ()
  7.  
  8. {
  9. int const SIZE = 100;
  10. int Element[SIZE]; //Array of SIZE Elements.
  11. cout << "Enter list of integers" << endl;
  12. int i = 0;
  13. int x;
  14. cin >> x;
  15. while ( i < SIZE && x!=0)
  16. {
  17. Element[i] = x;
  18. i++;
  19. cin >> x;
  20. }
  21. int sum = compute_sum(Element, i);
  22.  
  23. int k = 0;
  24. while (k < i)
  25. {
  26. cout << Element[k];
  27. k++;
  28. }
  29. cin.ignore().get();
  30. return 0;
  31.  
  32. }
  33.  
  34. double compute_sum( int const Element[], int const i)
  35. {
  36. int sum = 0;
  37. for (int z = 0; z < i; z++)
  38. {
  39. sum = sum + Element[i];
  40. }
  41. return(sum);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement