Question: 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
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 << X[1] << ' ' << X[2] << ' ' << X[3] << ' ' << xPtr << " : " << *xPtr << endl;
cout << "Array content prior to pointer manipulation "; // 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.
*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 -63 to +101.
- Using standard array notation, print all values in the array on one line, separated by a space
- Using array offset notation, print all values in the array, from last index to first, on one line, each separated by a space
- Using pointer notation, print all negative values on one line, each separated by a space
- Using pointer offset notation, print all positive values on one line, each separated by a space
Reminder:
array notation myArray[ x ];
array offset notation *(myArray + x);
pointer notation * arrayPtr;
pointer offset notation *(arrayPtr + x);
Question 3
Starting with the shortest possible C++ program, have it display to the console the name of the executable that is running and its argument count.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
