notes exam. No electronic resources will be allowed. 1. Which of the following is not true for arrays in C?

ECE285: Prog. for Electrical and Computer Engineers Sample Exam 2 1. This will be a closed book/notes exam. No electronic resources will be allowed. 1...
7 downloads 2 Views 198KB Size
ECE285: Prog. for Electrical and Computer Engineers Sample Exam 2 1. This will be a closed book/notes exam. No electronic resources will be allowed. 1. Which of the following is not true for arrays in C?

ANSWER: B

a) C stores arrays in row major form b) The elements of an array of length n are indexed from 0 to n c) if an array contains elements of type T, then each element of the array is treated as if it were a variable of type T d) None of the above 2. Which of the following is not true for arrays in C? a) b) c) d)

An array can be given an initial value at the time it’s declared If an initializer is present, the length of the array must be explicitly stated The compiler uses the length of the initializer to determine the array length None of the above

3. Which of the following is not true for a C function? a) b) c) d)

ANSWER: B

ANSWER: B

The return type of a function is the type of value that the function returns Functions may return arrays The body of a function may include both declarations and statements Variables declared in the body of a function can’t be examined or modified by other functions

4. What is correct prototype for the function given below?

ANSWER: C

int sum(int a[], int n) { int sum=0; for(int i=0, i

Suggest Documents