COP 3223 Section 1 Exam #2



COP 3223 Section 1 Exam #2

Form A

Fall 2003

10/29/03

Lecturer: Arup Guha

Directions: Answer all multiple choice questions on the scantron. Each question has a single correct answer. In case of ambiguities, choose the most accurate answer. Each of these questions is worth 2 points for a correct answer. Incorrect answers and questions left blank are worth 0 points. The free response questions are located on a separate answer sheet. The point values for these questions are denoted on that answer sheet. Partial credit will only be given on the free response portion of the exam. Hand in ONLY the scantron and answer sheet. Please properly bubble in your PID on your scantron form.

MULTIPLE CHOICE SECTION

1) What type of statement is required in a non-void function but not a void function?

a) loop b) if c) switch d) printf e) none of the above

2) What information is not necessary in a function prototype?

a) name of the function b) name of the formal parameters e) none of

c) return type of the function d) type of the formal parameters the above

3) Which of the following function calls always reads in a single character from the input stream?

a) read b) printf c) scanf d) getchar e) none of the above

4) What is the numerical value of the expression 'J'-'A'?

a) 0 b) 9 c) 10 d) 11 e) none of the above

5) What would the function call isdigit(9) return?

a) 0 b) 1 c) 2 d) 9 e) none of the above

6) What is the output of the following segment of code?

int x=3, y=5, *z;

z = &x;

y = *z + 4;

*z = 16;

z = &y;

*z = 13;

printf("x=%d, y=%d\n", x, y);

a)x=3, y=5 b)x=13, y=16 c)x=16, y=13

d)x=16, y=7 e)none of the above

7) Which of the following could be a valid expression?

a) &x b) &3 c) &(x+3) d) choices a and c

e) none of the above

8) What type of parameter is an array in a function?

a) pass by value b) pass by reference c) could be either a or b

d) neither a nor b e) none of the above

9) The following function calculates the hypotenuse of a right triangle with legs of lengths x and y. (For example, hyp(3,4) should return 5.) Which of the following choices completes the function below properly?

double hyp(double x, double y) {

_________________________

}

a)return x+y; b)return x^2+y^2; c)return x*x-y*y;

d)return x*x+y*y; e)none of the above

The following function counts all the blank characters in the input character array letters with the length length.

int cntspaces(char letters[], int length) {

int cnt=0, index;

for (index=0; index0; b)index ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download