Question
C++ with comments Question 1 Use the following code snippet as the basis for a program to test all possible combinations of pointer manipulation .
C++ with comments
Question 1
Use the following code snippet as the basis for a program to test all possible combinations of pointer manipulation. Each of the 10 combinations must be tested separately since the pointer may move and array values may be changed:
int X[] = { 3, 7, 11, 17, 23 };
int * xPtr = & X[2];
cout << "Array content prior to pointer manipulation "; cout << X[1] << ' ' << X[2] << ' ' << X[3] << ' ' << xPtr << " : " << *xPtr << endl;
// replace AAA in the following statement with selection from list of 10 pointer actions below, one at a time
cout << AAA << endl;
cout << endl << "Array content after ptr manipulation" << endl;
cout << X[1] << ' ' << X[2] << ' ' << X[3] << ' ' << xPtr << " : " << *xPtr << endl;
Generate an extremely concise summary report explaining the result of each of these pointer actions when inserted in place of AAA above. The report must identify: were any array values changed and, if the pointer moved, where and when it moved, and what value was output. The summary should group together any commands that produce identical results. The summary must be less than 100 words total. Its possible some of these combinations wont compile.
*++xPtr
(*++)xPtr
++*xPtr
++(*xPtr)
(++*)xPtr
*xPtr++
(*xPtr)++
*(xPtr)++
*(xPtr++)
*(++xPtr)
Question 2
Create an array of 100 integers, with values randomly generated to be in the range of -73 to +124 (include both extremes).
Reminder:
array notationmyArray[ x ];
array offset notation*(myArray + x);
pointer notation* arrayPtr;
pointer offset notation*(arrayPtr + x);
Question 3
Starting with the shortest possible C++ program, modify your program so that it will display to the console the name of the executable that is running and each argument value passed into main. You must have at least two arguments.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started