Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int compute_sum( int Element[], int i);
- int main ()
- {
- int const SIZE = 100;
- int Element[SIZE]; //Array of SIZE Elements.
- cout << "Enter list of integers" << endl;
- int i = 0;
- int x;
- cin >> x;
- while ( i < SIZE && x!=0)
- {
- Element[i] = x;
- i++;
- cin >> x;
- }
- int sum = compute_sum(Element, i);
- int k = 0;
- while (k < i)
- {
- cout << Element[k];
- k++;
- }
- cin.ignore().get();
- return 0;
- }
- double compute_sum( int const Element[], int const i)
- {
- int sum = 0;
- for (int z = 0; z < i; z++)
- {
- sum = sum + Element[i];
- }
- return(sum);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement