Professional Documents
Culture Documents
159.102 Computer Science Fundamentals - Massey - Exam - S2 2019
159.102 Computer Science Fundamentals - Massey - Exam - S2 2019
159.102 Computer Science Fundamentals - Massey - Exam - S2 2019
102 CP
AKLI
MASSEY UNIVERSITY
AUCKLAND CAMPUS
EXAMINATION FOR
159.102 COMPUTER SCIENCE FUNDAMENTALS
Page 1 of 5 CoS
1902/159.102 CP
AKLI
(d) Which header file contains the declaration of the function scanf? [1]
(g) Would you expect an executable file that uses static libraries to be
bigger or smaller than one that uses dynamic libraries? [1]
Page 2 of 5 CoS
1902/159.102 CP
AKLI
2. (a) In a simplified empty file system, the file allocation table has 16 entries:
0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
The first two entries (each with a value of 0) are special and are where the
FAT and the directory are stored. A normal entry with a value of 1 means that
the corresponding sector on the disk is free. A normal entry with a value of 0
signifies the end of a chain of sectors. When allocating a new sector the lowest
numbered free sector is always chosen. The directory, which contains the
filenames and initial sectors, is always sorted alphabetically on the filename.
What do the FAT and directory contain after each of the following actions:
(i) Files f (4 sectors), then g (4 sectors) are added. [1]
(ii) File f is reduced to 2 sectors. [1]
(iii) File e (4 sectors) is added. [1]
(e) Write, as a decimal, the value of the 32-bit floating point number that is
represented by the hexadecimal number:
c281000016 [1]
(h) Assume that you already have a 15-element array a of the above structure,
which has been initialised with the data of 15 different smartphones.
Write a piece of C code that uses a loop to find the Huawei phone that has
the largest battery.
Print the details of this phone using your function in Question 2(g).
There will be a unique answer. [5]
Page 3 of 5 CoS
1902/159.102 CP
AKLI
(iii) Write a piece of C code that deletes the first Node in the list. [2]
(d) Assuming you have all the correct header files included and with the
variables defined in Question 3(c), which of the following statements are
correct?
Page 4 of 5 CoS
1902/159.102 CP
AKLI
4. (a) (i) What is the effect of these format specifiers when used with scanf?
%5s [1]
%[a-e] [1]
char c;
int j = 1, result;
char t[32];
The following lines of a valid C program are executed:
(iii) Making all whitespace "visible", what is left in the input buffer? [1]
(b) The recursive function y has two integer arguments m and n and
returns an integer.
(c) Using your function in Question 4(b) write a main function that prints
the value of y with the arguments of 26 and 7. [2]
+++++++
Page 5 of 5 CoS