Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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).

1. Using standard array notation, print all values in the array on one line, separated by a space
2. Using array offset notation, print all values in the array, from last index to first, on one line, each separated by a space
3. Using pointer notation, print all negative values on one line, each separated by a space
4. Using pointer offset notation, print all positive (>=0) values on one line, each separated by a space

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

What are your research interests?

Answered: 1 week ago

Question

=+10. Did you clearly project the brand's USP?

Answered: 1 week ago