You are on page 1of 3

quiz_7.3.

11

Page 1 of 3

quiz_7.3.11

Part 1 of 1 Question 1 of 5 void f(int *ip) { static int dummy = 5; ip = &dummy; printf("%u\n",ip); } int main() { int *ip; f(ip); printf("%u",ip); } A. some values B. 0 some value C. error D. none of the above

5.0 Points 1.0 Points

Answer Key: D Question 2 of 5 int main() { int realarray[2]={1,2}; int *array = &realarray[-1]; int i; for(i=0;i<2;i++) { printf("\t%d",*array); array++; } } A. error B. garbage values C. 1 2 D. garbage value 1 E. 0 1 1.0 Points

Answer Key: D Question 3 of 5 1.0 Points

https://amritavidya.amrita.edu:8444/portal/tool/2afef5a5-107f-4b54-ab79-e40164a6aed1/js... 4/15/2011

quiz_7.3.11

Page 2 of 3

main() { extern i; printf("%d\n",i); { int i=20; printf("%d\n",i); } } A. 20 20 B. garbage value 20 C. linker error D. 0 20

Answer Key: C Question 4 of 5 int main() { int val=1234; int* ptr=&val; printf("%d %d",val,*ptr++); } A. 1234 1234 B. 1235 1235 C. 1234 1235 D. 1235 1234 1.0 Points

Answer Key: A Question 5 of 5 char buf [ ] = "Hello world!"; char * buf = "Hello world!"; In terms of code generation, how do the two definitions of buf, both presented above, differ? A. The first definition certainly allows the contents of buf to be safely modified at runtime; the second definition does not. B. The first definition is not suitable for usage as an argument to a function call; the second definition is. C. The first definition is not legal because it does not indicate the 1.0 Points

https://amritavidya.amrita.edu:8444/portal/tool/2afef5a5-107f-4b54-ab79-e40164a6aed1/js... 4/15/2011

quiz_7.3.11

Page 3 of 3

size of the array to be allocated; the second definition is legal. D. They do not differ -- they are functionally equivalent. E. The first definition does not allocate enough space for a terminating NUL-character, nor does it append one; the second definition does.

Answer Key: D

https://amritavidya.amrita.edu:8444/portal/tool/2afef5a5-107f-4b54-ab79-e40164a6aed1/js... 4/15/2011

You might also like