Docsity

Computer Sciences Exam: Data Representation, Memory Addressing, and C Programming, Prove d'esame di Computer Graphics

Toggle sidebar
bg1
Computer Sciences – 23/06/2017 Duration: 2h
SURNAME:
NAME:
B1
STUDENT ID:
PROFESSOR:
Question 1
Result
Given the following decimal numbers, determine the
corresponding binary value expressed in Sign and
Magnitude (SM) and 2’s Complement (2C) on 8 bits:
-105
121
-105 SM: ________________
-105 2C: _________________
121 SM: _________________
121 2C: _________________
Question 2
Which is the minimum size of the address bus to be able to access all the bytes in a 4GB RAM?
Report all the steps:
Question 3
Describe the instruction cycle in a microprocessor.
pf2

Anteprima parziale del testo

Scarica Computer Sciences Exam: Data Representation, Memory Addressing, and C Programming e più Prove d'esame in PDF di Computer Graphics solo su Docsity!

Computer Sciences – 23/06/2017 Duration : 2h

SURNAME: NAME:

STUDENT ID: B

PROFESSOR:

Question 1 Result Given the following decimal numbers, determine the corresponding binary value expressed in Sign and Magnitude (SM) and 2’s Complement (2C) on 8 bits:

  • 121

- 105 SM: ________________

- 105 2C: _________________

121 SM: _________________

121 2C: _________________

Report all the steps:

Question 2 Which is the minimum size of the address bus to be able to access all the bytes in a 4GB RAM?

Report all the steps:

Question 3

Describe the instruction cycle in a microprocessor.

Computer Sciences – 23/06/2017 Duration : 2h

Question 4 (PROGRAMMING)

You are asked to implement a program in C for managing the database of a city public transportation center. The information is stored in a file whose name is passed as command line argument. Each line in the file contains: the ID number of the public transport bus, the number of route the bus serves, the geometric coordinates in meters (abscissa and ordinate, i.e., x-axis and y-axis) and the time in seconds (all the time values belong to the same day) when the bus is checked. For example, the file can contain:

We make the following assumptions:  The number of lines is not known a priori and the fields are separated by spaces;  The bus ID is always 4 digits;  The bus route number is maximum 2 digits;  The geometric coordinates are indicated by two positive integers of up to 5 digits each;  Time is indicated by the total number of seconds passed since the beginning of the day (Max 5 digits);  The lines are sorted according to the time value;  The buses are always moving from time of the first check to time of the last check;  There are at most 100 different buses.  Multiple lines can describe the same bus at different times.

The program receives the following parameters from the command line: 1) the name of the file containing the database and, 2) a flag.  If the flag is “-d”, the program must print the distance traveled by each bus during the day (based on the available geometric coordinates) in meters (rounded to closest integer), indicating the time of the first check and last check (in format of hh:mm:ss).  If the flag is “-v”, the program must print the average speed in km/h (keep one decimal number) of each bus during the day (as the total traveled distance divided by the time between the first and the last check). C:> prog.exe trasporto.txt – d 2187: 2317 m. - First check: 05:00:00 – Last check: 5:20: 3002: 2195 m. – First check: 05:01:40 – Last check: 5:20:

C:> prog.exe trasporto.txt – v 2187: 6.9 km/h 3002: 7.2 km/h