Quelpr

CAPE Computer Science Unit 1 · 2013 · Paper 2 · Question 5(b)

Write a function swap that accepts an integer array and two valid integers pos1 and pos2 representing locations in the array, and swaps the contents of these two locations.

The mark scheme is shown once you've answered.

Practise this question

Other parts of this question

  1. 5(a)Explain TWO differences between compilers and interpreters.[6 marks]
  2. 5(c)Write a C program that reads two space-separated integers from a text file named 'in.dat', then prints them in reverse order followed by their sum and product.[7 marks]
  3. 5(d)Write a program that prompts the user to enter an integer r and prints r!, where 0! = 1 and r! = r(r-1)(r-2)...1 for r > 0.[8 marks]

More practice: the rest of this paper · more Procedural Programming Constructs in C questions · all CAPE Computer Science Unit 1 past papers