📄 c1.txt
字号:
(c) II only
(d) II and III only
Correct answer is (a)
Your score on this question is: 0.00
Feedback:
See section 1.4.2 of the course notes.
(d)
7.
Consider the function factorial() defined as follows.
int factorial(int n) {
if (n == 1) return n;
return n * factorial(n - 1);
}
How many activation records of factorial are allocated by invocation of the expression factorial(4)?
(a) 4
(b) 0
(c) 1
(d) 5
Correct answer is (a)
Your score on this question is: 7.14
Feedback:
See section 1.4.2 of the course notes.
(a)
8.
Consider the program given below.
#include
int callee(void) {
int count = 5;
printf("%d ", (int) &count);
return count;
}
int main (int argc, char *argv[]) {
int count = 4;
count = callee();
printf("%d ", (int) &count);
return 0;
}
Which of the following describes the output of the program?
(a) Two different integers are printed, and the value of neither can be determined from the information given.
(b) 5 is printed twice on the same line.
(c) One integer is printed twice, and its value cannot be determined from the information given.
(d) 5 and 4 are printed, in that order on the same line.
Correct answer is (a)
Your score on this question is: 7.14
Feedback:
See section 1.4.1 of the course notes.
(a)
9.
The Visual C++ Memory window displays
(a) the contents of memory, interpreted in one of several ways, without the associated variable names
(b) the contents of memory, interpreted as 32-bit integers, without the associated variable names
(c) the names and values of variables in memory, interpreted as 32-bit integers no matter what the variables' types
(d) the names and values of variables in memory, interpreted in one of several ways
Correct answer is (a)
Your score on this question is: 0.00
Feedback:
See section 1.3.3 of the course notes.
(c)
10.
Consider the following segment of a C program.
int i = 99;
int a[100];
i = a[i + 1];
Which of the following is true of the segment?
(a) Execution will fail because a has the wrong size.
(b) i will have the value 99 at the end of any execution of the segment.
(c) When executed, the program will be prematurely terminated by the operating system because of an illegal memory access.
(d) i will have the value of the last element of the array a at the end of any execution of the segment.
Correct answer is (b)
Your score on this question is: 7.14
Feedback:
See section 1.3.5 of the course notes.
(b)
11.
Which of the following are true of the effect that optimizations have on the machine code generated by compilers?
1. The resulting code will be faster and/or smaller.
2. The resulting code will be clearer.
3. The resulting code will be harder to debug.
(a) I, II, and III
(b) I and II only
(c) I and III only
(d) I only
Correct answer is (c)
Your score on this question is: 0.00
Feedback:
See section 1.5.3 of the course notes.
(a)
12.
Immediately after the CPU executes an instruction that is neither a branch nor a jump instruction, the program counter
(a) has a value that cannot be determined without further information
(b) is incremented to point to the following instruction
(c) remains unchanged
(d) is incremented by one
Correct answer is (b)
Your score on this question is: 0.00
Feedback:
See section 1.5.2 of the course notes.
(d)
13.
A CPU register is a word of CPU memory that
(a) is explicitly loaded and unloaded from normal memory by compiler-generated instructions
(b) is automatically loaded when a CPU instruction refers to a word of normal memory
(c) records the results of periodic CPU diagnostics
(d) houses a critical variable for the duration of the execution of a program
Correct answer is (a)
Your score on this question is: 7.14
Feedback:
See section 1.5.3 of the course notes.
(a)
14.
Which of the following computations may be performed by exactly one CPU instruction?
1. a = 5;
2. a = b + c * 5;
3. for (i = 0; i < 10; i += a[i++]);
(a) II only
(b) I and II only
(c) I only
(d) I, II, and III
Correct answer is (c)
Your score on this question is: 7.14
Feedback:
See section 1.5.1 of the course notes.
(c)
1.
Integrated programming environments make it difficult to mix and match tools from different sources. This is
(a) bad, because all the tools will then have the same user interface
(b) good, because it ensures compilation is not done incrementally by accident
(c) good, because tools from different sources cannot be made to interact with each other
(d) bad, because no single vendor is likely to be the source of all the best tools
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See section 1.1.4 of the course notes.
(c)
2.
Which of the following is able to describe a computation at the highest level of abstraction?
(a) logic Gates
(b) C++ code
(c) C code
(d) machine code
Correct answer is (b)
Your score on this question is: 7.14
Feedback:
See section 1.1.2 of the course notes.
(b)
3.
Within Visual C++, which of the following will reveal the value of a variable when the program is stopped at a breakpoint?
1. Placing the mouse pointer over the variable name in the source file window.
2. Inserting a printf() in the program.
3. Typing the variable name on the "Watch" window.
(a) III only
(b) I, II, and III
(c) I and III only
(d) II and III only
Correct answer is (c)
Your score on this question is: 7.14
Feedback:
See section 1.2.3 of the course notes.
(c)
4.
When using a debugger to find the cause of a program's incorrect behavior,
(a) the program is usually executed to the point at which the behavior occurs and then executed backwards to find the cause
(b) it is fastest to start by stopping the debugger long before the behavior appears
(c) it is often necessary to start the program multiple times under the debugger
(d) the faulty code fragment must first be identified
Correct answer is (c)
Your score on this question is: 0.00
Feedback:
See section 1.2.4 of the course notes.
(b)
5.
Consider the following program.
int i;
int j = 1;
int callee(int number) {
int plusone;
plusone = number + 1;
return plusone;
}
int main (int argc, char *argv[]) {
if (j == 1) return callee(i);
return j;
}
Which of the following are allocated in the activation record immediately after the function callee() is invoked?
(a) plusone only.
(b) i only.
(c) plusone and number only.
(d) i, j and number only.
Correct answer is (c)
Your score on this question is: 7.14
Feedback:
See section 1.4.2 of the course notes.
(c)
6.
Consider the following function.
int factorial(int n) {
if (n == 1) return n;
return n * factorial(n - 1);
}
How many activation records are "popped" when it is invoked by the expression factorial(4)?
(a) 5
(b) 4
(c) 0
(d) 1
Correct answer is (b)
Your score on this question is: 7.14
Feedback:
See section 1.4.2 of the course notes.
(b)
7.
What does the following program print?
void callee(int * count) {
count++;
}
int main (int argc, char *argv[]) {
int count = 4;
callee(&count);
printf("%d", count);
return 0;
}
(a) 4
(b) 5
(c) cannot be determined from the information given.
(d) 8
Correct answer is (a)
Your score on this question is: 0.00
Feedback:
See section 1.4.1 of the course notes.
(c)
8.
Consider the function factorial() defined as follows.
int factorial(int n) {
if (n == 1) return n;
return n * factorial(n - 1);
}
How many activation records of factorial are allocated by invocation of the expression factorial(4)?
(a) 0
(b) 4
(c) 1
(d) 5
Correct answer is (b)
Your score on this question is: 7.14
Feedback:
See section 1.4.2 of the course notes.
(b)
9.
Consider the following code fragment.
int a;
int b;
int main(int argc, char *argv[]) {
int c;
int d;
...
/* some code */
}
Which of the following must be true?
(a) The value of *d is closer to the value of *c than to the value of *a.
(b) The values of &a and &b are closer to each other than the values of &c and &d.
(c) The values of *a and *b are closer to each other than the values of *c and *d.
(d) The value of &d is closer to the value of &c than to the value of &a.
Correct answer is (d)
Your score on this question is: 7.14
Feedback:
See section 1.3.1 of the course notes.
(d)
10.
Consider the following segment of a C program.
int i = 99;
int a[100];
i = a[i + 1];
Which of the following is true of the segment?
(a) i will have the value 99 at the end of any execution of the segment.
(b) When executed, the program will be prematurely terminated by the operating system because of an illegal memory access.
(c) i will have the value of the last element of the array a at the end of any execution of the segment.
(d) Execution will fail because a has the wrong size.
Correct answer is (a)
Your score on this question is: 0.00
Feedback:
See section 1.3.5 of the course notes.
(b)
11.
A branch instruction
(a) sets the program counter to one of two possible values
(b) sets the program counter to one of many possible values
(c) unconditionally sets the program counter to its operand
(d) increases the program counter by a fixed amount
Correct answer is (a)
Your score on this question is: 0.00
Feedback:
See section 1.5.2 of the course notes.
(b)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -