📄 ssd6-quiz.txt
字号:
(b) II and III only
(c) II only
(d) III only
Correct answer is (a)
Your score on this question is: 7.14
Feedback:
See section 1.4.2 of the course notes.
(a) The program starts executing by calling the function main().
--------------------------------------------------------------------------------
8.
What is printed as a result of execution of the following program?
#include <stdio.h>
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) It cannot be determined from the information given.
(d) 8
Correct answer is (b)
Your score on this question is: 7.14
Feedback:
See section 1.4.1 of the course notes.
(b)
--------------------------------------------------------------------------------
9.
Consider the following code.
char a[100];
a[99] = *((char *) (((int) &a[0]) + 4))
If integers are 32 bits wide, which of the following values is equal to a[99]?
(a) a[0] + 4
(b) the integer stored in the bytes a[4], a[5], a[6] and a[7]
(c) a[3]
(d) a[4]
Correct answer is (d)
Your score on this question is: 7.14
Feedback:
See section 1.3.5 of the course notes.
(d)
--------------------------------------------------------------------------------
10.
The Visual C++ Memory window displays
(a) the names and values of variables in memory, interpreted as 32-bit integers no matter what the variables' types
(b) the contents of memory, interpreted as 32-bit integers, without the associated variable names
(c) the contents of memory, interpreted in one of several ways, without the associated variable names
(d) the names and values of variables in memory, interpreted in one of several ways
Correct answer is (c)
Your score on this question is: 0.00
Feedback:
See section 1.3.3 of the course notes.
(a)
--------------------------------------------------------------------------------
11.
Which of the following is a good reason (are good reasons) to equip the CPU with small amounts of fast memory?
To make the design of the compiler simpler
To make some CPU instructions smaller
To make some CPU instructions faster
(a) II only
(b) I, II, and III
(c) II and III only
(d) III only
Correct answer is (c)
Your score on this question is: 0.00
Feedback:
See section 1.5.3 of the course notes.
(d)
--------------------------------------------------------------------------------
12.
Suppose that, using a tool such as the memory window of Visual C++, we found that a certain set of contiguous memory locations contained the integer 0xC605CD623A8365000000. What could these memory locations hold?
the integer 0xC605CD623A8365000000
a string
a CPU instruction
(a) I only
(b) I and II only
(c) III only
(d) I, II, and III
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See section 1.5.1 of the course notes.
(c)
--------------------------------------------------------------------------------
13.
We want the variable factorialfunc to hold the address of the first instruction of the following function:
int factorial(int n) {
if (n == 1) return n;
return n * factorial(n -1);
}
How would we declare the variable?
(a) factorial() * factorialfunc;
(b) int (*factorialfunc)(int);
(c) int (int) * factorialfunc
(d) we can't: C cannot extract the addresses of instructions.
Correct answer is (b)
Your score on this question is: 7.14
Feedback:
See section 1.5.2 of the course notes.
(b)
--------------------------------------------------------------------------------
14.
How many return addresses does a C function have as a program executes?
(a) one
(b) as many as the number of times it is invoked
(c) as many as the number of return statements within the function
(d) two, one for each branch
Correct answer is (b)
Your score on this question is: 7.14
Feedback:
See section 1.5.2 of the course notes.
(b)
1.
Compared to a sequence of machine code instructions, a fragment of C code
(a) may describe the same algorithm
(b) is the native way to program most computers
(c) does not engage any transistors during its execution
(d) describes the actions of the computer, not just of the CPU
Correct answer is (a)
Your score on this question is: 0.00
Feedback:
See section 1.1.2 of the course notes.
(d)
--------------------------------------------------------------------------------
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 (c)
Your score on this question is: 7.14
Feedback:
See section 1.1.2 of the course notes.
(c)
--------------------------------------------------------------------------------
3.
When debugging using Visual C++, which of the following are possible through the Watch window?
The program's execution can be stopped.
The value of an arbitrary C expression can be calculated.
The value of a program variable can be set.
(a) II and III only
(b) I, II, and III.
(c) III only
(d) II only
Correct answer is (a)
Your score on this question is: 7.14
Feedback:
See section 1.2.3 of the course notes.
(a)
--------------------------------------------------------------------------------
4.
In Visual C++, a Win32 Console Application is
(a) built by using sophisticated "Application Wizards"
(b) the simplest type of application Visual C++ can generate
(c) the status window of the Visual C++ environment
(d) a program that is able to control the operating system of a windows computer
Correct answer is (b)
Your score on this question is: 0.00
Feedback:
See section 1.2.1 of the course notes.
(d)
--------------------------------------------------------------------------------
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) plusone and number only.
(c) i, j and number only.
(d) i only.
Correct answer is (b)
Your score on this question is: 7.14
Feedback:
See section 1.4.2 of the course notes.
(b)
--------------------------------------------------------------------------------
6.
At which of the following times is an activation record created?
When a program starts executing.
Every time a function is invoked.
When a variable is declared.
(a) II only
(b) I and II only
(c) II and III only
(d) III only
Correct answer is (b)
Your score on this question is: 7.14
Feedback:
See section 1.4.2 of the course notes.
(b) The program starts executing by calling the function main().
--------------------------------------------------------------------------------
7.
What does the following program print?
int callee(int * count) {
count++;
return *count;
}
int main (int argc, char *argv[]) {
int count = 4;
int retval;
retval = callee(&count);
printf("%d", retval);
return 0;
}
(a) 4
(b) cannot be determined from the information given.
(c) 8
(d) 5
Correct answer is (b)
Your score on this question is: 7.14
Feedback:
See section 1.4.1 of the course notes.
(b)
--------------------------------------------------------------------------------
8.
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) 1
(b) 4
(c) 0
(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 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 of the last element of the array a 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 99 at the end of any execution of the segment.
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See section 1.3.5 of the course notes.
(c)
--------------------------------------------------------------------------------
10.
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 value of *d is closer to the value of *c than to the value of *a.
(c) The values of &a and &b are closer to each other than the values of &c and &d.
(d) The values of *a and *b are closer to each other than the values of *c and *d.
Correct answer is (a)
Your score on this question is: 7.14
Feedback:
See section 1.3.1 of the course notes.
(a)
--------------------------------------------------------------------------------
11.
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) remains unchanged
(c) is incremented by one
(d) is incremented to point to the following instruction
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See section 1.5.2 of the course notes.
(c)
--------------------------------------------------------------------------------
12.
Which of the following are true of the effect that optimizations have on the machine code generated by compilers?
The resulting code will be faster and/or smaller.
The resulting code will be clearer.
The resulting code will be harder to debug.
(a) I, II, and III
(b) I and III only
(c) I only
(d) I and II only
Correct answer is (b)
Your score on this question is: 0.00
Feedback:
See section 1.5.3 of the course notes.
(d)
--------------------------------------------------------------------------------
13.
A jump instruction
(a) unconditionally sets the program counter to its operand
(b) increases the program counter
(c) changes a pointer to point to the next element of an array
(d) changes the program counter only if its operand is equal to zero
Correct answer is (a)
Your score on this question is: 7.14
Feedback:
See section 1.5.2 of the course notes.
(a)
--------------------------------------------------------------------------------
14.
Programs compiled for an Intel Pentium processor do not execute properly on a SPARC processor from Sun Microsystems because
(a) the assembly mnemonics for the same "opcode" are different in the two processors
(b) copyrights regarding code cannot be violated
(c) the memory of a SPARC CPU is numbered from top to bottom
(d) the operation codes understood by the two processors are different
Correct answer is (d)
Your score on this question is: 7.14
Feedback:
See section 1.5.1 of the course notes.
(d)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -