// This program uses subscript notation with a pointer // variable and pointer notation with an array name. #include #include using namespace std; int main() { const int NUM_COINS = 5; double coins[NUM_COINS] = {0.05, 0.1, 0.25, 0.5, 1.0}; double *doublePtr; // Pointer to a double int count; // Array index // Assign the address of the coins array to doublePtr. doublePtr = coins; // Display the contents of the coins array. // Use subscripts with the pointer! cout << setprecision(2); cout << "Here are the values in the coins array:" << endl; for (count = 0; count < NUM_COINS; count++) cout << doublePtr[count] << " "; cout << endl; // Display the contents of the coins array again, but // this time use pointer notation with the array name! cout << endl << "And here they are again:" << endl; for (count = 0; count < NUM_COINS; count++) cout << *(coins + count) << " "; cout << endl; return 0; }