DOC PREVIEW
MIT 16 070 - Introduction to Computers and Programming

This preview shows page 1-2-3 out of 10 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Name: ________________________________ 16.070 Introduction to Computers and Programming Examination 3/10/03 2:05p - 2:55p Prof. I. Kristina Lundqvist Spring 2002 Grading Section: Question 1 (12) Question 2 (6) Question 3 (5) Question 4 (2) Question 5 (6) Question 6 (30) Question 7 (30) Question 8 (9) Total 100 You have 50 minutes to take this examination. Do not begin until you are instructed to do so. This is a closed book examination. No external materials are permitted, including calculators or other electronic devices. All answers must be written in the examination paper. This examination consists of 8 questions and 9 pages (not including this cover page). Count the number of pages in the examination paper before beginning and immediately report any discrepancy to the invigilator. Should you need to do so, you may continue your answers on the back of pages. When you have finished, remain seated and raise your hand; an invigilator will collect your paper.1I. When talking about operating systems, the concept of a process is very important. a) Are a program and a process the same thing? Motivate your answer. (4) b) Please explain shortly what a context switch is (2) c) What is multitasking? (2) d) List the items that comprise the state of a process? (4)2II. What is the process known as the machine cycle? (6) III. a) What are three essential aspects of the von Neumann computer architecture? (3) b) Does a personal computer have a von Neumann architecture? Explain in a few words. (2) IV. What is the most interesting concept you have learnt in class so far? (2)3V. Complete the following number conversion table. (6) Decimal Binary Hexadecimal 17 0100 1101 A5 VI. Ada Programming a) Given the following specification and body, the user wrote a test program called Test J. Will the procedure Test compile? If it does not compile, specify the line(s) that generates the error and correct it (them). You must not change the order of the parameters in the procedure call(s). (5) Package Specification 1. package Exam_Questions is 2. 3. procedure Ada_Read_1 ( 4. Input_Integer : in Integer; 5. Input_Float : in Float ); 6. 7. end Exam_Questions; Package Body 1. with Ada.Text_Io; 2. with Ada.Integer_Text_Io; 3. with Ada.Float_Text_Io; 4. 5. 6. package body Exam_Questions is 7. procedure Ada_Read_1 ( 8. Input_Integer : in Integer; 9. Input_Float : in Float ) is 10. begin 11. Ada.Text_Io.Put("This is an integer"); 12. Ada.Integer_Text_Io.Put(Input_Integer); 13. Ada.Text_Io.New_Line; 14. Ada.Text_Io.Put ("This is a float: "); 15. Ada.Float_Text_Io.Put(Input_Float); 16. Ada.Text_Io.New_Line; 17. end Ada_Read_1; 18. end Exam_Questions;4Test Program 1. with Exam_Questions; 2. use Exam_Questions; 3. procedure Test is 4. Test_Integer : Integer; 5. Test_Float : Float; 6. 7. begin 8. Test_Integer :=1; 9. Test_Float := 2.0; 10. 11. Ada_Read_1(Test_Integer, Test_Float); 12. Ada_Read_1(Test_Float, Test_Integer); 13. end Test; b) What is the value of count displayed? Justify your answer (a 2-line answer is fine!). (5) 1. with Ada.Text_Io; 2. with Ada.Integer_Text_Io; 3. 4. procedure Loop_Test is 5. Count : Integer := 0; 6. 7. begin 8. for I in 1.. 10 loop 9. for J in 1 .. 5 loop 10. if (I rem 2 = 0) then 11. exit; 12. end if; 13. Count:=Count+1; 14. end loop; 15. end loop; 16. Ada.Integer_Text_Io.Put(Count); 17. Ada.Text_Io.New_Line; 18. 19. end Loop_Test;5c) Write an Ada procedure to generate and display the first ‘n’ Fibonacci numbers, where ‘n’ is specified by the user. (20) Fibonacci numbers are the numbers in the Fibonacci sequence 0, 1, 1, 2, 3, 5, 8, 13, 21, . . ., each of which, after the second is the sum of the two previous ones. Hint: What is the mathematical formula that generates a Fibonacci sequence6VII. Assembly Programming a) Write an algorithm to carry out integer division of two positive 7-bit integers. Assume that the numbers are stored in 8-bit two’s complement form. (15) Integer division is defined as follows: when m is divided by n, we obtain two integers, q and r, called quotient and remainder, respectively, with r between 0 and n-1, such that the equation m = n*q + r is satisfied.7b) Implement your algorithm in assembly language. (15) Hint : Think of repeated subtraction J8VIII. For each question, select the correct answer from the choices, and write the chosen letter in the box provided next to each question. (9) For the circuit shown, what input combination(s) would cause the output to be high? a. A = 0 & B = 0 b. A = 0 & B = 1 c. A = 1 & B = 1 d. All of the above A NOR gate has an output logic 1 when … a. Any input is a logic 1 b. All inputs must be logic 1’s c. Any input is a logic 0 d. All inputs must be logic 0’s The 2’s complement of the binary number 0111 0010 is … a. 1000 1100 b. 1000 1101 c. 1000 1110 d. None of the above The von Neumann bottleneck is … a. also called a SISD – single-instruction stream, single-data stream b. a technique allowing the steps in the machine cycle to overlap c. the central bus, when CPU and controllers compete for bus access d. the ability of a controller to access main memory Typical operations performed by the ALU is … a. AND, OR, ROTATE, LOAD, STORE b. AND, OR, SHIFT, ROTATE c. Input and output d. AND, OR, ROTATE, JMP, BRANCH9Will the the following definition … Procedure foo is TYPE Months IS (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec); PACKAGE Month_IO IS Ada.Text_IO.Enumeration_IO(Enum => Months); Foo_month : Months Begin … Month_IO.Get(Foo_month); End; a. Compile b. Compile with errors c. Throw an exception while running d. What’s foo? The value of 1008 is… a. 10010 b. 410 c. 6410 d. What’s X8? The value of 100000002 in the big-endian system a. 12810 b. 6410 c. 1000000010 d. 25610 The value of 010101012 in the little-endian system is a. 8510 b. 12510 c. 0101010110 d.


View Full Document

MIT 16 070 - Introduction to Computers and Programming

Documents in this Course
optim

optim

20 pages

Load more
Download Introduction to Computers and Programming
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Introduction to Computers and Programming and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Introduction to Computers and Programming 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?