4. (TCO 5) For the statement int *p, how many bytes of storage are allocated on
ID: 3653559 • Letter: 4
Question
4. (TCO 5) For the statement int *p, how many bytes of storage are allocated on a Pentium class system using 32-bit addressing? (Points : 4) One Two Four Eight 5. (TCO 5) Consider the following definitions and statements. void myFunction( double * dptr ); double data[10]; Which statement correctly passes the entire array to myFunction( )? (Points : 4) myFunction(data); myFunction(&data); myFunction(*data); myFunction(data[0]); 6. (TCO 5) Given a pointer variable called myData, which points to an instance of the following structure, which of the following statements assigns the value 123.45 to the dval field of the structure? struct Data { int ival; double dval; char cval; }; (Points : 4) dval = 123.45; *mydata = 123.45; mydata->dval = 123.45; mydata.dval = 123.45; 7. (TCO 5) After the following program compiles, what is the data type of foo2? #include using namespace std; int main () { int foo; int *foo2; foo2 = &foo; foo = 1234; cout << *foo2 << end1; return 0; } (Points : 4) int pointer to int object addressExplanation / Answer
A ) 4 bytes ,since pointer are basically address , so they use 32 bit since the underlying machine is 32 bit addressable.
B) void myFunction( double * dptr ); double data[10];
the way to pass an array to a function is to pass its base address which will be pointed by the pointer declared in the arguments of called function *dptr.
the correct answer is myFunction(data);
C) struct Data { int ival; double dval; char cval; };
struct Data *mydata;
since we have declare pointer to structure , we will access the element of structure by -> operator.so assigning 123.45 to dval of mydata is
mydata->dval = 123.45;
d) since foo2 is declared as pointer to integer and points to foo.
So datatype of foo2 is pointer to int.
the value of *foo2 will be value assigned to foo.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.