Question: #include using namespace std; int main(){ struct foo_t{ int x[100]; int var1; int y[10]; } foo; int var2; long i; int *p, *q; short int

#include using namespace std;

int main(){ struct foo_t{ int x[100]; int var1; int y[10]; } foo; int var2; long i; int *p, *q; short int *s; long int *l; struct foo_t bar [50];

for (i =0; i <100; i++) foo.x[i]=100 + i; for (i =0; i <10; i++) foo.y[i]=200 + i; foo.var1 = 250;

cout << sizeof (*s) << " "; cout << sizeof (*p) << " "; cout << sizeof (*l) << " "; q = (int *) &foo; cout << q << " "; p=&(foo.x[5]); cout << *p << " "; // POINT 1 q = (int *) &var2; cout << q << " "; q = p + 16; cout << *q << " "; i = ((long) p) + 16; q = (int *) i; cout << *q << " "; s = (short *) i; cout << *s << " "; l = (long *) i; cout << *l << " "; q = p+95; cout << *q << " "; q = p+98; cout << *q << " "; i = ((long) p) + 17; q = (int *) i; cout <<*q << " ";

// MOD // size of pointers cout<< "size of pointer in bits int " << sizeof(int*)*8 << endl; cout<< "size of pointer in bits long " << sizeof(long*)*8 << endl; cout<< "size of pointer in bits short " << sizeof(short*)*8 << endl;

// fill in the blanks

//fill in the blanks below for the question.

q = p + -----;

cout << q << ;

q = ( int ) ( ( ( long) p) + -----) ;

cout << q << ;

p = ( int ) bar;

(p + ---------) = 500;

cout << bar [ 8 ] . var1 << ;

}

Part a: The program contains three blanks. Fill the rst two with appropriate integer constants to print 205 for both new outputs. Fill in the third blank in the program to print 500.

Part b. Does your compiler allocate local scalar variables growing up or down in memory? Explain how you know this from your program output.

Please explain it as well.

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!