#include #include //for setw #include using namespace std; //If p is a pointer, p[0] means the same thing as *p int main() { double a[] { //Gpd news: the stock price is trending upwards. 120.00, 130.25, 126.00, 121.00, 132.50, 128.00, 122.00, 133.75, 128.95 }; int n {size(a)}; //how many prices in the array for (int i {1}; i < n-1; ++i) { cout << "$" << fixed << setprecision(2) << (a[i-1] + a[i] + a[i+1]) / 3 << "\n"; } cout << "\n"; for (double *p {begin(a) + 1}; p < end(a) - 1; ++p) { cout << "$" << fixed << setprecision(2) << (p[-1] + p[0] + p[1]) / 3 << "\n"; } return EXIT_SUCCESS; }