c++ program for sum of 10 array elements

  1. include<iostream>
  2. using namespace std;
  3. int main ()
  4. {
  5.     int arr[10], n, i, sum = 0, pro = 1;
  6.     cout << "Enter the size of the array : ";
  7.     cin >> n;
  8.     cout << "\nEnter the elements of the array : ";
  9.     for (i = 0; i < n; i++)
  10.     cin >> arr[i];
  11.     for (i = 0; i < n; i++)
  12.     {
  13.         sum += arr[i];
  14.         pro *= arr[i];
  15.     }
  16.     cout << "\nSum of array elements : " << sum;
  17.     cout << "\nProduct of array elements : " << pro;
  18.     return 0;
  19. }

Comments

Popular posts from this blog