practice exam a

practice exam a - PART ONE (50 points). Each question is...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
PART ONE (50 points). Each question is worth 5 points. Circle the correct answer. 1. Which of the following is legal ? int i=5, *p; (a) printf("%d", *p); (b) p = *i; (c) p = (double *) 1307; (d) (double) p = 3.0; Key: a 2. Which of the following is WRONG for array initiation? (a) int a[]={3, 4, 5, 6}; (b) int a[4] = {1, 2}; (c) int a[2][3] = {1, 2, 3, 4, 5, 6}; (d) int a[2][3] = {{1, 2}, {3, 4}, {5, 6}}; Key: d 3. Which of the following is WRONG for the initialization of Strings? (a) char s[] = {‘a’, ‘b’, ‘c’, ‘\0’}; (b) char s[] = “abc”; (c) char *p; p[0]= “abc”; (d) char p[2]; p[0]= ‘A’; p[1] = ‘\0’; Key: c 4. Which of the following is TRUE between Arrays and Pointers? int a[100], *p; (a) p = &a; (b) p = a[0]; (c) p = a+1 is equivalent to p = a[1] (d) p = a+1, *p = a[1] Key: d 5. Which of the following explanations is FALSE ? (a) A call-by-value mechanism means a copy of the value of the expression is made and passed to the function. (b) A call-by-reference mechanism means the actual argument list in a function reference contains the true address of a variable sent to the function (c) You can initialize and modify a variable with type static const. (d) External and static variables that are not explicitly initialized by the programmer are initialized to zero by the system. Key: c 6. Which of the statements is true about the following code? int main()
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
{ char a[7]= {‘c’,’p’,’s’,’c’,’2’,’0’,’6’}; char *p = a+2; } 1. p contains the address of the third array element 2. p contains the base address of the array 3. p contains the value of ‘p’ 4. p contains the value of ‘s’ (a) 1 only (b) 2 only (c) both 1 and 3
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

practice exam a - PART ONE (50 points). Each question is...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online