INTRODUCTION TO COMPUTERS 3rd exam solution
Question 1 Assuming that a string is stored as a sequence of ASCII codes corresponding to its individual characters, what string would be represented by the following bit pattern: 110011110110111111110000111100110111010001110111 Note that even-parity check is adopted for each character.
Solution of Q1 Ans: Oopstw 11001111 →O 01101111 → o 11110000 → p
Question 2 Assuming that a string is stored as a sequence of ASCII codes corresponding to its individual characters, and that odd-parity check is adopted for each character. How would the following string: I_love_NSYSU_#1? be represented?
Solution of Q2 Ans: I_love_NSYSU_#1? I→01001001 e→ 11100101 S→11010011 ?→ 10111111 _→11011111 _→ 11011111 U→11010101 l→11101100 N→11001110 _→11011111 o→11101111 S→11010011 #→00100011 v→01110110 Y→11011001 1→00110001 01001001110111111110110011101111011101101110010111011111110011101101001111011 001110100111101010111011111001000110011000110111111
Question 3 The decimal value 105 is represented by the binary number 01101001. Please store this number in 64 bits using the IEEE double- precision floating point format.
Solution of Q3 Ans: 0,10000000101,1010010000000000000000000 000000000000000000000000000
Question 4 Suppose the following 64 bits represent a number in the IEEE double-precision floating point format: 11000000001011000000000000000000000000 00000000000000000000000000 What is the decimal value corresponding to the above bit sequence?
Solution of Q4 Ans: 100000000102=102610 =(-1)X (2) 1026−1023 X(1.11)2 =(-1110)2 =(-14)10
Question 5 Suppose outputArea is a text box defined by <div id="outputArea"></div> Show the web page that would be produced by the following while loop:
Solution of Q5 Ans: 10 7 4 1
Question 6 Suppose outputArea is a text box defined by <div id="outputArea"></div> Show the web page that would be produced by the following while loop:
Solution of Q6 Ans: 2 4 DONE WITH SECOND!
Question 7 Suppose outputArea is a text box defined by <div id="outputArea"></div> Show what would be displayed in outputArea by the following codes:
Solution of Q7 Ans: 因While為無窮迴圈,網頁會無回應。
Question 8 Suppose outputArea is a text box defined by <div id="outputArea"></div> Show what would be displayed in outputArea by the following codes:
Solution of Q8 Ans: num=4
Question 9 Suppose N is a positive integer. Please write JavaScript codes, using while loop, to get the sum of all positive odd integers less than or equal to N.
Solution of Q9 Ans:設inputBox的輸入為N則執行以下 function
Question 10(1/2) Consider the following program:
Question 10(2/2) Please show the page after the user types 5 in the startBox text box and pushes the button.
Solution of Q10
Question 11(1/2) Suppose outputArea is a text box defined by <div id="outputArea"></div> Show what would be displayed in outputArea by the following codes:
Question 11(2/2)
Solution of Q11 Ans: 1 2 4 8 16 Finished!
Question 12(1/2) Consider the following machine language program stored in the memory: Memory address 0: 1000000100001010 Memory address 1: 1000000100101001 Memory address 2: 1000000101001000 Memory address 3: 1010000100110001 Memory address 4: 1010000100111011 Memory address 5: 1000001001100111 Memory address 6: 1111111111111111 Memory address 7: 0000000000000001 Memory address 8: 0000000000000100 Memory address 9: 0000000000000001 Memory address 10: 0000000000000010
Question 12(2/2) Note that instructions are placed at memory addresses 0 to 6, and data are placed at memory addresses 7 to 10. What are the content of memory addresses 7 to 10 after this program is executed?
Solution of Q12(1/2) 1000000100101001→R1=M[9] →R1=110 Ans: 1000000100001010 →RO=M[10] →R0=210 1000000100101001→R1=M[9] →R1=110 1000000101001000→R2=M[8] →R2=410 1010000100110001→R3=R0+R1 →R3=310 1010000100111011→R3=R2+R3 →R3=710 1000001001100111→M[7]=R3 →M[7]=710 1111111111111111 →half
Solution of Q12(2/2) Ans: M[7]=00000000,00000111 M[8]=00000000,00000100 M[9]=00000000,00000001 M[10]=0000000,000000010
Question 13 What sequence of assembly-language instructions corresponds to the instructions at memory addresses 0 to 6 of the machine language program of Problem 12?
Solution of Q13 Ans: LOAD R0 10 LOAD R1 9 LOAD R2 8 ADD R3 R0 R1 STORE 7 R3 HALT
Question 14 Please write an assembly-language program which stores the value 0 in memory address 5.
Solution of Q14 Ans: SUB R0 R0 R0;//把Register 0清成0 STORE 5 R0;//把Register 0的值寫入Mem 5 HALT;