Quelpr

CAPE Computer Science Unit 1 · 2014 · Paper 2 · Question 5(d)

A nonprofit organization is asking for donations for a worthy cause. They hope to raise $100,000. All donations are stored in a file called 'donations.txt'. The first line of the file gives the amount the organization hopes to raise. Each line thereafter contains the amount of each donation. The last line of data in the file contains -1 only.

Write a C program that determines and outputs to a file, "funds.txt", the total funds raised and how many donations were made. (You may not use arrays in your solution.)

The mark scheme is shown once you've answered.

Practise this question

Other parts of this question

  1. 5(a)(i)A stream of characters making up the source program is read from left to right and grouped into tokens.[1 mark]
  2. 5(a)(ii)A piece of code is transformed to make it more efficient without changing its output or side effects.[1 mark]
  3. 5(b)Explain the role of a 'watch' in programming.[2 marks]
  4. 5(c)Write a C function which accepts an integer array and an integer variable indicating the size of the array. The function should return a count of the numbers…[6 marks]

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