Problem 1 18 pts - 1.5 pts each: Multiple Choice Questions
1. The first and last index numbers of a 1D array of size k will be
and
A. 0, k-1
B. 1, k-1
C. 1, k
D. 0, k
2. Which of the following can be legitimately passed to a function?
A. constant value
B. variable
C. array element
D. All of the above
3. An end-of-file, for file stream infile can be determined using:
A. infile.eof()
B. infile.fail()
C. infile.bad()
D. infile.is_open()
4. What is the output of the C++ code below?
1. int i=1, j=3, k=7, n=5;
2. cout << i+j*k-k%n;
A. 16
B. 26
C. 20
D. 21
5. What is the output of the following code fragment?
1. int b[4] = {4, 5, 2, 1};
2. for (int i=2; i>=0; i--)
cout << b[i] + b[i+1];
A. 382
B. 381
C. 380
D. 379