Advertisement
sheredega

Task #9

Dec 10th, 2022
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int n;
  6.     cout << "Enter the size of array: ";
  7.     cin >> n;
  8.     int* array = new int [n];
  9.     int sum = 0;
  10.     int prod = 1;
  11.     cout << "Enter the elements of array:\n";
  12.     for (int i = 0; i < n; i++) {
  13.         cin >> array[i];
  14.         sum += array[i];
  15.         prod *= array[i];
  16.     }
  17.     cout << "Your array: ";
  18.     for (int i = 0; i < n; i++) {
  19.         cout << array[i] << " ";
  20.     }
  21.     cout << "\nThe sum of array elements = " << sum << endl;
  22.     cout << "The product of array elements = " << prod;
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement