159.102 Computer Science Fundamentals - Massey - Exam - S1 2017
159.102 Computer Science Fundamentals - Massey - Exam - S1 2017
159.102 Computer Science Fundamentals - Massey - Exam - S1 2017
102 CP
ALB
Internal
MASSEY UNIVERSITY
ALBANY CAMPUS
EXAMINATION FOR
159.102 COMPUTER SCIENCE FUNDAMENTALS
The exam paper will be made available on the Massey University Library website
in due course website.
The examination question paper is not to be removed from the exam room.
Page 1 of 5
1701/159.102 CP
ALB
Internal
1. (a) Draw a diagram that shows how a disk is organised into sectors and
tracks. [2]
(b) Describe the term "seek time" when applied to a hard disk. [1]
(g) The function prototype for the main function of the program test.c is:
int main(int argc, char *argv[]);
(iii) What will output.txt contain after the program has run? [1]
Page 2 of 5
1701/159.102 CP
ALB
Internal
2. (a) In a simplified empty file system, the 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 c (5 sectors), then a (2 sectors), then b (4 sectors) are
added. [
1]
(ii) File a is deleted. [1]
(iii) File c is extended by another 3 sectors. [1]
(e) Write, as a decimal, the value of the 32-bit floating point number that is
represented by the hexadecimal number:
3f40000016 [1]
(f) Declare a C structure that can contain data describing a sheet of paper.
Its height and width (both integers in millimetres), its colour (a string, e.g.
"red", "yellow" etc.) and whether it has lines (an unsigned char – 0 is false,
1 is true). [1]
(g) Write a C function area that has an element of the above structure
passed as an argument (via a pointer). The function returns the area of
the paper (height * width). [2]
(h) Assume that you already have a 20-element array a of the above
structure, which has been initialised with the data of 20 different paper
types. Write a piece of C code that uses the function in Question 2(g) and
loops, to find and then print whether the "blue" paper with the largest area
has lines or not. There will be a unique answer. [5]
Page 3 of 5
1701/159.102 CP
ALB
Internal
3. (a) Write a makefile, that when used with the program make, automates the
creation of a program test.exe.
test.exe depends on two source files test.c and f.c.
A header file test.h is also included in both of the source files. [2]
(c) Declare a C structure Node that describes a node in a linked list. The
linked list consists of one data item (an integer), and a single pointer to the
next node in the list. [1]
(e) Write a piece of C code that inserts a node (containing the number 45) at
the beginning of the linked list in Question 3(d). [4]
int n = 5;
char s[80] = "Massey";
char *p;
int *ip;
Page 4 of 5
1701/159.102 CP
ALB
Internal
4. (a) (i) What is the effect of these format specifiers when used with scanf?
%x [1]
%[aeiou] [1]
char c;
char s[80];
int i, result;
(iii) Making all whitespace "visible", what is left in the input buffer? [1]
Q(1) is 1
Q(2) is 1
(c) Using your function in Question 4(b) write a main function that prints the
value of Q(5), and by adding a comment to your program, state what the
answer will be.
[4]
+++++++
Page 5 of 5