Question: Compile and run the following program; #include using namespace std; int main() { int i = 5; int data[5] = {10, 20, 30, 40, 50};

Compile and run the following program; #include  using namespace std; int main() { int i = 5; int data[5] = {10, 20, 30, 40, 50}; int *p = &i; // point p to the address of i. cout << endl; cout << "For this exercise, study the code carefully, then compile and run"< address of beginning of array // NOTE 2: I could also have done: p = &data[0]; // where I take the address of a single integer, in this case the address // of the first element of data. cout << "now p is equal to data (i.e., it points to the beginning of the array data[])"<(text[0]) << " '"<(text[1]) << " '"<(text[2]) << " '"<(text[3]) << " '"< ." << endl; cout << "We'll see a use for this in our next lab, but generally"<(pc); // but we can force it to work using a re-interpret_cast int *pi = reinterpret_cast(pc); long *pl = reinterpret_cast(pc); long long *pll = reinterpret_cast(pc); float *pf = reinterpret_cast(pc); double *pd = reinterpret_cast(pc); cout << "First, what everything points to:" << endl; cout << "my_cstring : " << my_cstring << endl; cout << endl; cout << "char ptr pointing to c-string does what you expect..."< 

Determine why it gives the results it does, and answer the questions posed in the output. Make a text file with an explanation of what each section is demonstrating, with answers to all the questions, and submit that as part of your lab work.

It may help to put the code next to the output so you can study the output and make sense of what the code is doing. You may also find it helpful to use the debugger and single-step through the program, examining the output after each statement.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!