Question: Q1. Given the following program, trace the output by drawing the memory model as the program runs . #include using namespace std; int main() {

Q1. Given the following program, trace the output by drawing the memory model as the program runs . #include using namespace std; int main() { int x = 60; int *ptr; ptr = &x; *ptr *= 20; cout using namespace std; int main( ) { int *p; int val[5] = {1, 2, 3, 4, 5}; // array p = &val[0]; cout << p << " " << &val[0] << endl; for ( int i = 0 ; i <5 ; i++ ) { cout << "val[" << i << "]: value is " << *(p+i) << " and address is " << p+i << endl; } system("PAUSE"); return 0; } output 0031FED0 0031FED0 val[0]: value is 1 and address is 0031FED0 val[1]: value is 2 and address is 0031FED4 val[2]: value is 3 and address is 0031FED8 val[3]: value is 4 and address is 0031FEDC val[4]: value is 5 and address is 0031FEE0 Press any key to continue . . .

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!