#define ALLOW_INSTRUCTOR_CODE /*************************************************************************** *************************************************************************** ****** BEFORE BEGINNING OR TURNING IN THIS EXERCISE IT IS EXTREMELY ****** ****** IMPORTANT THAT YOU READ, FULLY UNDERSTAND, AND ADHERE TO THE ****** ****** REQUIREMENTS STATED IN THE DOCUMENT TITLED, "ASSIGNMENT ****** ****** SUBMISSION REQUIREMENTS", DOWNLOADABLE FROM THE COURSE WEB ****** ****** SITE. ****** *************************************************************************** **************************************************************************/ /*************************************************************************** ************* C/C++ Programming 2: Assignment 4 - Exercise 3 ************* ******** BEGIN EXERCISE REQUIREMENT - THIS MUST BE A "C++" PROGRAM ******** *************************************************************************** (3 points) Using only fixed array declarations and initializations (no dynamic memory allocation), create a 4D pointer array named ptr4D to replace the following multidimensional array: float fArray[DIM0][DIM1][DIM2][DIM3] where DIM0, DIM1, DIM2, and DIM3 have values of 2, 3, 4, and 5, respectively. *************************************************************************** ************************ END EXERCISE REQUIREMENT ************************* **************************************************************************/ /*************************************************************************** * BEFORE PRINTING THIS ASSIGNMENT TO TURN IN, DELETE THIS COMMENT AND * EVERYTHING ABOVE IT. **************************************************************************/ /* * TODO: * REPLACE THIS COMMENT WITH YOUR TITLE BLOCK. */ /* * TODO: * REPLACE THIS COMMENT WITH YOUR C++ CODE, PLUS ANYTHING NECESSARY TO * SUPPORT MY TEST CODE BELOW. DO NOT INCLUDE ANY UNNEEDED HEADER FILES! */ /*************************************************************************** * BEFORE PRINTING THIS ASSIGNMENT TO TURN IN, DELETE THIS COMMENT AND * EVERYTHING BELOW IT. **************************************************************************/ /* ***** Change nothing below this comment without instructor permission. **** * Everything that follows was written to help test/verify your code. You * do not need to understand the details of my code to write yours! */ #ifdef ALLOW_INSTRUCTOR_CODE int main() { int i, j, k, l, value; // Store all values. value = 0; for (i = 0; i < DIM0; ++i) for (j = 0; j < DIM1; ++j) for (k = 0; k < DIM2; ++k) for (l = 0; l < DIM3; ++l) ptr4D[i][j][k][l] = float(value++); // Test all stored values. value = 0; for (i = 0; i < DIM0; ++i) for (j = 0; j < DIM1; ++j) for (k = 0; k < DIM2; ++k) for (l = 0; l < DIM3; ++l) if (ptr4D[i][j][k][l] != value++) { cout << "Error at: ptr4D[" << i << "][" << j << "]["; cout << k << "][" << l << "]\n"; return EXIT_FAILURE; } cout << "Success!\n"; return EXIT_SUCCESS; } #endif