Test 2 _A_ - answers

Test 2 _A_ - answers - 1 Multiple Choice Short Answer 1...

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

View Full Document Right Arrow Icon
1. Which of the following must be included in a function prototype (circle all that apply)? a. Return value b. Argument names c. Estimated run-time d. Argument datatypes e. Function name f. Function body g. Header file answer: d, e 2. Which of the following functions could work to swap the value of two variables (circle all that apply)? a. int swap(int a, int b); b. int swap(int *a, int b); c. int swap(double *a, double *b); d. bool swap(int a, double *b); e. void swap(int *a, int *b); answer: c, e 3. Consider the following code segment: char *p = "This is some string."; Which of the following will properly traverse the entire string (circle all that apply)? a. for (char *i = p; *i; ++i) { . .. } b. for (int i = 0; i < strlen(p); i++) { . .. } c. for (char *e = p+strlen(p); p<e; ++p) { . .. } d. do { . .. } while (*(++p)); answer: a, b, c. d 4. Which of the following accesses the number 2 in the array (circle all that apply): int a[] = {1,4,3,8,2,3,9}; a. a[5]; b. a[4]; c. 5[a]; d. 4[a]; e. *(5+a); f. *(a+4); answer: b, d, f
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/17/2008 for the course CS 1372 taught by Professor Smith during the Fall '07 term at Georgia Tech.

Page1 / 5

Test 2 _A_ - answers - 1 Multiple Choice Short Answer 1...

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

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