Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n;
- cout << "Enter the size of array: ";
- cin >> n;
- int* array = new int [n];
- int sum = 0;
- int prod = 1;
- cout << "Enter the elements of array:\n";
- for (int i = 0; i < n; i++) {
- cin >> array[i];
- sum += array[i];
- prod *= array[i];
- }
- cout << "Your array: ";
- for (int i = 0; i < n; i++) {
- cout << array[i] << " ";
- }
- cout << "\nThe sum of array elements = " << sum << endl;
- cout << "The product of array elements = " << prod;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement