1
CS31: Introduction to Computer Science I
Midterm Practice Problems 2
This example midterm is extended from Brian Choi’s file, used in Spring 2011
Problem 1
True False An array index begins with 0. True False If there is a function that does not require any parameters, you can
- mit parentheses when calling it.
True False Constant variables can be modified only in the main() function. True False Consider the array is declared as: int a[10];, there are 10 elements in the array. True False In the C-string (a.k.a char array), we use ‘\n’ to represent the end of a string. True False Function parameters are pass-by-reference by default (e.g., void foo(int n)) True False We can put a floating number as an index of an array (e.g., a[2.3]) True False If we declare a C-string (a.k.a char array) of 10 elements, that means this string can hold up to 10 letters (i.e., char arr[10] = “1234567890”;)
Problem 2
True False Which will func1() print? void func1() { if (0 == ‘\0’) cout << “True” << endl; else cout << “False” << endl; } True False Which will func2() print? void func2() { if (0 == true) cout << “True” << endl; else cout << “False” << endl; }