G51PRG

Sample Hello World program

Lecture Notes

05/10/2011 — printf("Programming");
06/10/2011 — Procedures, Parameters, Values and VariablesSimple Procedure Example
07/10/2011 — Procedures, Parameters, Values and VariablesSimple Variable Example
12/10/2011 — Variables, Scopes and Operator Precedence
13/10/2001
14/10/2011 — Operators, Conditionals and LoopsCelsius to Fahrenheit example
19/10/2011 — Operators, Conditionals and LoopsExamples
20/10/2001
21/10/2011 — Word Counting InterludeWord Counting Program
26/10/2011
27/10/2011 — More Loops: For and Nest
28/10/2011 — Pointers and scanf()Pointer Fun With Binky video
02/11/2011 — scanf()scanf() example
03/11/2011 — fopen("Lecture14", "r")Some Simple File I/O examples
04/11/2011 — ArraysArray examples
10/11/2011 — Arrays, Pointers and Strings
11/11/2011 — StringsCaesar cipher example
16/11/2011 — Strings (again)
17/11/2011 — Structures
18/11/2011 — More Structures
23/11/2011 — Arrays of Structures
24/11/2011
25/11/2011 — The Linked List
30/11/2011
01/12/2011 — Recursion
02/12/2011 — Bits and Pieces

The examples from the last few lectures (structure, dynamic arrays, linked lists and recursion) are available in this archive. If you would like to play with the PostScript files generated from some of the examples then I suggest you take a look at GhostScript which is available for most platforms. If you are running MacOS X, then you can feed the PostScript directly into Preview for display.


Essential Reading :)

The developers at Media Molecule (developers of ‘Little Big Planet’) discuss one reason why it is important to understand how a computer works at the architecture level in this blog post, even when you are programming in high-level languages such as C or C++.


Coursework

The fourth PRG coursework is now available. All PRG coursework is assessed and will count to your final mark. Please see the notes below about coursework submission.

Exercicse Title CW Submit ID Due Date Weighting Feeback
1 Variables and Functions 414 24/10/2011 15% General Feedback Document
2 Octal and Hidden Characters
Sample output for ascii.set
418 08/11/2011 20% General Feedback Document
3 Arrays, Files and Hidden Characters 439 29/11/2011 15% General Feedback Document

Exercise Four

For Exercise Four, you have all been randomly allocated a different problem to solve. You can find your allocation for exercise 4 in this PDF. If you are missing from that file then please contact either Alex or Michael as soon as possible. Please note that you must do the exercise set and not choose one of the others because it looks ‘easier’.

This exercises will be assessed by your tutor (notpreceptor) both by them looking at your code and by you giving a short presentation during your weekly tutorials in the last two weeks of term. To ensure that your tutor has time to look at your code before the presentation, your code should be submitted (in the usual fashion via cw submit) by the 6th december (at 23:59 as usual). This exercise accounts for 25% of your final G51PRG mark.

The descriptions of the three different exercises can be found below:
Exercise 4a — Text Justification
Exercise 4b — Extracting Headings
Exercise 4c — Binary Multiplication

Coursework 5

The coursework five specification is here. You can find the skeleton file, clock.c and sample binaries here. The CW submission ID for this coursewokr is 455, and the coursework is due in on 18/01/2012 at 23:59.


Fun Exercises

As well as the formal courseworks above, we are also providing some more ideas for simple programs you might like to try writing. The best way to learn to program is to keep writing programs, and so trying these will sharpen your programming skills.

These exercises won't be assessed, and we won't be providing feedback or model solutions but feel free to discuss them with your friends and try to complete them.

Fun 1 — Guess the Number
Fun 2 — The Computer guesses the Number
Fun 3 — Clock Patience Introduction


Coursework Submission

Coursework submission is by electronic submission of your source code using the cw submit command on the school's UNIX machines.

Your file should be named username-g51prg-ex1.c, where username should be your username and ex1 should be modified as appropriate for the exercise being submitted. If your file is not named this, then you can rename it either via Windows (use your H:\ drive) or via the UNIX command line:

mv myfile.c srb-g51prg-ex1.c

Please take special care when typing this as you could either delete your source code, or overwrite another file without warning. Read and reread the command before you press ENTER.

With the file correctly named, you can now submit it using the cw submit command like so:

cw submit srb-g51prg-ex1.c

and follow the prompts that are supplied. You will need to enter the correct CW Submit ID listed in the table above (but check it matches that presented in the menu—if they don't match use the one provide in the menu).

If you wish to submit multiple files, then you will need to submit them all at the same time, like this:

cw submit srb-g51prg-ex1a.c srb-g51prg-ex1b.c srb-g51prg-ex1c.c

If you submit them separately then each submission will overwrite any previous submissions, resulting with only the last file being submitted.

Please note:We want the C source files submitted, not the compiled programs submitted, please make sure you submit the correct file.

More details about the cw system can be found here.