LANGUAGE C Compile and run this program Determine why it giv

LANGUAGE C++

Compile and run this program. 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.

Name your file pointers_questions.txt  (or pointers_questions.docx)

==================THE SAMPLE CODE IS POSTED BELOW=================

Solution

#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...\"<
LANGUAGE C++ Compile and run this program. Determine why it gives the results it does, and answer the questions posed in the output. Make a text file with an ex

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site