Quelpr

CAPE Computer Science Unit 2 · 2010 · Paper 2 · Question 2(b)

A one-dimensional array num contains 20 unsorted integers. Write C code to accept an integer target from the user, search for it in num, print the location if found, or print an appropriate error message if not present.

The mark scheme is shown once you've answered.

Practise this question

Other parts of this question

  1. 2(a)(i)Describe how the selection sort algorithm works to sort a set of 10 integers in ascending order.[10 marks]
  2. 2(a)(ii)Draw the array after the first, second, and third passes of the selection sort algorithm (three diagrams in all).[3 marks]
  3. 2(c)State when binary search should be used on an array.[2 marks]

More practice: the rest of this paper · more Searching and Sorting Algorithms questions · all CAPE Computer Science Unit 2 past papers