1#include <iostream>
2using namespace std;
3
4int main() {
5
6 // initialize an array without specifying size
7 double numbers[] = {7, 5, 6, 12, 35, 27};
8
9 double sum = 0;
10 double count = 0;
11 double average;
12
13 cout << "The numbers are: ";
14
15 // print array elements
16 // use of range-based for loop
17 for (const double &n : numbers) {
18 cout << n << " ";
19
20 // calculate the sum
21 sum += n;
22
23 // count the no. of array elements
24 ++count;
25 }
26
27 // print the sum
28 cout << "\nTheir Sum = " << sum << endl;
29
30 // find the average
31 average = sum / count;
32 cout << "Their Average = " << average << endl;
33
34 return 0;
35}