Supervision questions: Programming in C and C++
This is the set of questions for my supervisions in Programming in C and C++. I will typically email you a list of question numbers before each supervision, but if not, attempt the next two or three. (More questions will appear here as I set them, so come back if you want to make an early start on some of the future work.)
Administrativa & handing in work
I expect you to make a good attempt at producing solutions to the relevant questions before each supervision. I prefer submissions by email (PDF or text format). Please submit your work 24 hours before the supervision. If you want to submit a hard copy of the work to student administration, please hand it in before 17:00 two days before the supervision (i.e. before Wednesday, 17:00 for a Friday afternoon supervision) as I will have to scan it. Remember that Student Administration is closed on weekends.
When emailing me regarding supervisions, please only use my lab address, or your email will be misfiled and may slip by unnoticed:
The mark allocation (whilst very approximate) should give you a rough idea of how you should divide your time between the questions, as well as how much credit I expect a similar question to be worth in the exam. It will also serve as a guide for me when marking the questions.
Some of these questions are asking you to write code. In his case, please submit the source code and a transcript of it compiling and running, as shown in the example below:
malte@cassiopeia:~$ gcc -o foo foo.c malte@cassiopeia:~$ ./foo Hello World! malte@cassiopeia:~$
If there is a particular part of the course you would like explaining, or questions you have about the lectures (independent of whether they are covered by the questions or not), please let me know in an email before the supervision so that I can prepare appropriately.
Supervision 1: The C language
- Lecture 1, exercise 2 [2 marks]
- Lecture 1, exercises 3 and 4 [5+7 marks]
- What does the static keyword mean in
- global context (outside a function), and
- local context?
- Lecture 2, exercises 3 and 4 [4+5 marks]
- Why is the const keyword useful and when do we use it? [3 marks]
- For each of the following pointer expressions, explain what action it will perform (assume that p is a pointer to an int, q is a pointer to a char, and r is a pointer to a structure):
- q -= *p++,
- Lecture 3, exercise 1 [2 marks]
- What are the semantics of the sizeof keyword for different possible arguments (consider a local variable, a global variable and a type name)? [3 marks]
- Lecture 4, exercise 2 [15 marks]
- Optional bonus question: Describe how Duff's device (Lecture 4, slide 17) works. [5 marks]