Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ program running in visual studios. Part 2: Write some code using pointers He

ID: 3814313 • Letter: C

Question

C++ program running in visual studios.

Part 2: Write some code using pointers Here's the basic program for next few parts of this lab: include Kiostream using namespace std; int main int i 5, j 51, k 62 int data [5] 10 20 30, 40, 50 char my cstring (81 the fox int *p NULL; char *pc NULL; do something useful with the arrays and the pointers and put some clean-up code to delete any dynamically allocated variables cout "done "Kendl; #ifdef WIN32 system ("pause #endif return 0; Aside note on fifde f #endif These lines create a "conditional compile Visual Studio defines a precompiler constant called WIN32 while other compilers, like the Gnu C+ compiler, do not. Thus, the line system ("pause") is compiled in Visual Studio, but left out of a gnu compile. This line lets you run with the debugger in VS and pause your program before exiting, so the window doesn't disappear before you can read the output.

Explanation / Answer

2)

a.

p = &i;

cout<<p;

b.

p = &j;

cout<<p;

p = &k;

cout<<p;

c.

p = data;

cout<<p;

d.

p = &data[2];

cout<<p;

e.

p = &i;

*p = 23;

p = data;

*p = 27;

p = &data[2];

*p =39;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote