Week 7 Exam Skeleton
COMP1511 Week 7 Practice Exam
September 2017
Time allowed: 1 Hour
Total number of questions: 3
Total number of marks: 10
Questions are not worth equal marks
Answer all questions
Answer each question in a SEPARATE file. Each question specifies
the name of the file to use. These are named after the corresponding
question number, i.e. Question 1 is in a file called q1.c
Make sure you use EXACTLY this file name.
Submit these files using the submit
command as described in each
question. You may submit your answers as many times as you like. The
last submission ONLY will be marked.
If you have only a partial solution and the exam is about to end, submit it anyway.
The exam environment allows you to run a limited set of commands so you can test and debug your answers.
The exam environment logs all your actions.
The exam environment does not allow access to files in your CSE account or any other CSE account. It does not allow access to the web or other network access
A C reference sheet is available on-line. Manual entries are also available. No other documents or files will be available to you.
Question 1 (2.5 marks)
Write a C function that ___________________________.
Place your answer to this question in a file named q1.c
Your function should take _______________ parameters: ________________.
It must have this prototype: ___________________________.
Your function should return ________________.
For example, if the array contains ________________
Your function should return __________, because _________________.
Assumptions
You can assume _________________________.
Your function should not print anything.
Your submitted file must only contain one function: _________________.
Your submitted file must not contain a main function. The autotest script will supply its own main function to test your ____________ function.
If you do write a main function to do your own testing, make sure you
comment it out or delete it before running autotest
or submitting your
file.
Testing and Submission
You can test your program using the autotest
command:
$ autotest q1 q1.c
Make sure you also do your own testing, as your code will be run through more tests after the exam.
If you compile a program without a main function dcc will give you an error. You can use the -c flag to stop this error message, e.g.:
$ dcc -c q1.c
Once you are satisfied with your solution, submit it by running
$ give q1 q1.c
Question 2 (3.5 marks)
Write a C function that ___________________________.
Your function should return ___________________________.
Place your answer to this question in a file named q2.c
Your function should take _______________ parameters: ________________.
It must have this prototype: ___________________________.
Your function should return ________________.
For example, if the input was: ________________
Your function should return __________, because _________________.
Assumptions
Your function should not print anything.
Your submitted file must only contain one function: ____________.
Your submitted file must not contain a main function. The autotest script will supply its own main function to test your ____________ function.
If you do write a main function to do your own testing, make sure you
comment it out or delete it before running autotest
, or submitting
your file.
Testing and Submission
You can test your program using the autotest
command:
$ autotest q2 q2.c
Make sure you also do your own testing, as your code will be run through more tests after the exam.
If you compile a program without a main function dcc will give you an error. You can use the -c flag to stop this error message, e.g.:
$ dcc -c q2.c
Once you are satisfied with your solution, submit it by running
$ give q2 q2.c
Question 3 (4 marks)
Write a C function that ___________________________.
Place your answer to this question in a file named q3.c
Your function should take _______________ parameters: ________________.
It must have this prototype: ___________________________.
Your function should return ________________.
For example, if the input was: ________________
Your function should return __________, because _________________.
As another example, if the input was: ________________
Your function should return __________, because _________________.
Assumptions
You can assume ____________________________.
You cannot assume _________________________.
Your function should not print anything.
Your submitted file must only contain one function: ____________.
Your submitted file must not contain a main function. The autotest script will supply its own main function to test your ____________ function.
If you do write a main function to do your own testing, make sure you
comment it out or delete it before running autotest
, or submitting
your file.
Testing and Submission
You can test your program using the autotest
command:
$ autotest q3 q3.c
Make sure you also do your own testing, as your code will be run through more tests after the exam.
If you compile a program without a main function dcc will give you an error. You can use the -c flag to stop this error message, e.g.:
$ dcc -c q3.c
Once you are satisfied with your solution, submit it by running
$ give q3 q3.c