Outline

Lectures and times

Assessments

Assessment Deadline Weight
Basic C test week 14 5%
Cpair week 18 35%
Cind week 21 35%
Java final week 24 25%

C deadlines

Assessment Deadline Weight
week 13
Basic C test week 14 5%
week 15
week 16
week 17
Cpair reading week 35%
week 19
week 20
Cind week 21 35%
week 22
Easter x3
week 23
Java test week 24 25%

C content

C assignment

You will complete the first C assignment individually. The second assignment will be done in pairs. Then the last will be done individually again.

I will randomly assign the pairs (within cohort) once you have submited the basic C test. If you don’t submit I won’t pair you up with anyone. I will also assign each pair to a TA who will be your supervisor for the rest of the unit.

Plagiarism

We had problems with plagiarism the year before last:

More on this later…

(From tiobe.com)

Family tree

C

Things written in C/C++

Python is actually a C program!

When C is good

When C is bad

Demo Python/C…

Compilers and interpreters

Python is interpreted and C is compiled but what does that mean?

Compilation

A compiler converts human code to machine code e.g.:

Human code:

int multiply(int a, int b)
{
  int c = a * b;
  return c;
}

Machine code (and assembly):

   0: 55                    push   %rbp
   1: 48 89 e5              mov    %rsp,%rbp
   4: 89 7d ec              mov    %edi,-0x14(%rbp)
   7: 89 75 e8              mov    %esi,-0x18(%rbp)
   a: 8b 45 ec              mov    -0x14(%rbp),%eax
   d: 0f af 45 e8           imul   -0x18(%rbp),%eax
  11: 89 45 fc              mov    %eax,-0x4(%rbp)
  14: 8b 45 fc              mov    -0x4(%rbp),%eax
  17: 5d                    pop    %rbp
  18: c3                    retq

Compilation in C

Running C code is a two-step process:

The computer can execute machine code directly (fast)

Python is interpreted

When you run your Python program it is not compiled to machine code. The interpreter reads the code and simulates executing it.

The interpreter itself is a C program that was compiled to machine code (by someone else).

How to learn C

Read the notes, and try out the examples. Do hte exercises and make sure that you know the answers to the questions.

Very important: you must actually try things. You can not learn to program simply by reading.

So go do it now…