当前位置:天才代写 > 考试助攻 > Cs计算机代考 计算机系统组织代写

Cs计算机代考 计算机系统组织代写

2023-06-26 14:58 星期一 所属: 考试助攻 浏览:390

Cs计算机代考

CSCI-UA.0201-003

Computer Systems Organization

Exam 1 Fall 2018 (time: 60 minutes)

Cs计算机代考 Questions vary in difficulty; it is strongly recommended that you do not spend too much time on any one question.

Notes:

  • If you perceive any ambiguity in any of the questions, state your assumptions clearly.
  • Questions vary in difficulty; it is strongly recommended that you do not spend too much time on any one question.
  • The exam consists of 5 pages, 5 questions, and a total of 50 points. Last paper is left intentionally blank, for you to use if you want.
  • You answer on the question sheet.

1.(5 points) Circle the correct answer among the choices given.  Cs计算机代考

If you circle more than one answer, you will lose the grade of the corresponding question.

(A) If you write a C program that consists of one C file, then we don’t need a linker:

1.True 2. False 3. depends on OS 4. depends on the hardware

(B) By seeing the following signed number: 0xFF0070FF we know for sure that it is:

  1. negative int
  2. negative short int
  3. negative floating point
  4. We do not know for sure

(C) Suppose we have a 32-bit machine. The size of “double” is:

  1. 4 bytes
  2. 8 bytes
  3. 2 bytes
  4. Depends on the compiler.     Cs计算机代考

(D) Suppose we have a 64-bit machine. The size of “double” is:

  1. 4 bytes
  2. 8 bytes
  3. 2 bytes
  4. Depends on the compiler.

(E) If we see a binary file that cannot be opened by a text editor, then it has been generated by (choose the most precise):

  1. the compiler
  2. the assembler 3. the linker
  3. 1 or 2
  4. 1 or 3
  5. 2 or 3

2. [6 points] For single precision floating point numbers, calculate the following and show all your steps (correct final answer without steps will not earn you any credits). You can leave your answer at the form: xyz*2abc   Cs计算机代考

  • The largest positive number (infinity is not counted):
  • The smallest positive non-zero number:

3.[8 points] Suppose you want to include this condition in your C code: if( x & mask) x is a char. You want the condition to be true if the third bit from the right of x is set to 1.

  • What value mask must have in binary?
  • What value mask must have in hexadecimal?
  • Suppose x = 1, will the condition be true? Show the value of x, mask, and x & mask in binary to justify.
  • What if x = -1? Show the value of x, mask, and x & mask in binary to justify.
Cs计算机代考
Cs计算机代考

4.Suppose we have the following piece of C code (%p in printf just prints the address in hex):

int main() 

{

foo(2);

}

foo(int x) 

{

printf(“The address of x is %p\n”, &x);

foo1(x-1);

}

foo1(int y) 

{

char k;

printf(“The address of y is %p\n”, &y);

scanf(“%c”, &k);

}

a.[3 points] If x is stored at address A1, and y at address A2, will A1>A2 always be true? Or will A2 > A1 always be true? Or can it sometime go this way and sometimes the other in different executions? Justify your answer.   Cs计算机代考

b.[4 points] k in foo1 is a char. Specify the range of numbers that k can present [Hint: You already know whether k is signed or unsigned, so don’t ask!]

c.[2 points] If the user inputs a number larger than the range that k can present, what will happen?

d.[2 points] When we reach the scanf line, how many stack frames exist in the memory?

5. Given the following piece of code:  Cs计算机代考

void process(int *x){

int y[10];

x = (int *)malloc(10*sizeof(int));

}

a.[4 points] How many bytes does the array of y[] consume? and how many does x[] consume?

  • Array x[] needs:
  • Array y[] needs:

b.[4 points] Where in memory is the array y[] stored? and where is x[] stored? (data, text, heap,or stack)  Cs计算机代考

  • x[] is stored in:
  • y[] is stored in:

c.[4 points] What happens to arrays x[] and y[] when the function process() returns?

d.[2 points] Suppose, instead of the malloc(), we want to make x points to array y[]. Write the C statement to do so.

e.[2 points] Why do we need the typecasting with malloc?

f.[4 points] Suppose that, after malloc is executed, x[0] is stored at address 1000. And assume that some extra code is written to initialize the array x[] as follows: x[0] = 0, x[1] = 1, …. till x[9] = 9. So element i of array x contains value i. What are the values stored in the following:

 

Cs计算机代考
Cs计算机代考

更多代写:加拿大留学生作业课业代写  网考作弊  美国组织学代写  留学生essay论文代写范文  留学论文代写  代写计算机作业

合作平台:essay代写 论文代写 写手招聘 英国留学生代写

 

天才代写-代写联系方式