Quelpr

CAPE Computer Science Unit 1 · 2009 · Paper 2 · Question 5(c)

Write a complete C program that prompts the user for 10 integers and writes them into a text file 'in.dat' (one per line), closes the file, reopens it, computes and prints the average of the integers, and outputs an appropriate error message if the file cannot be opened. Do not use arrays.

The mark scheme is shown once you've answered.

Practise this question

Other parts of this question

  1. 5(a)Describe the 'lexical analysis' and 'semantic analysis' stages of the translation process.[6 marks]
  2. 5(b)Write a C function that takes two distinct integer parameters, a and b, and returns the larger integer.[4 marks]

More practice: the rest of this paper · more Modular Programming and Data Structures questions · all CAPE Computer Science Unit 1 past papers