Quelpr

Modular Programming and Data Structures · CAPE Computer Science Unit 1

36 past-paper questions on Modular Programming and Data Structures, part of Programming, from every CAPE Computer Science Unit 1 paper on Quelpr.

  1. 5(c)15 marks· CAPE Computer Science Unit 1 · 2009 · Paper 2Write 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…
  2. 6(c)16 marks· CAPE Computer Science Unit 1 · 2009 · Paper 2Complete the main C program using the provided declarations to repeatedly read input data (id, hrs, rate) until sentinel ID 999 is entered, calculating daily salary and updating totalPay and numDays for each…
  3. 5(c)19 marks· CAPE Computer Science Unit 1 · 2010 · Paper 2Write a C program that reads employee records from 'salary.dat' (surname up to 30 characters, hours worked, hourly rate, deductions; ending with sentinel 'ENDDATA'), and calculates and prints the gross salary for each…
  4. 6(a)6 marks· CAPE Computer Science Unit 1 · 2010 · Paper 2Describe THREE different ways in which the programming style of the given code snippet can be improved, using line numbers in your response.
  5. 6(b)2 marks· CAPE Computer Science Unit 1 · 2010 · Paper 2What is the purpose of a 'struct' in C?
  6. 6(c)(i)6 marks· CAPE Computer Science Unit 1 · 2010 · Paper 2Write a function which accepts two unique integers, x and y, and returns the larger of the two. Show how your function would be called.
  7. 6(c)(ii)6 marks· CAPE Computer Science Unit 1 · 2010 · Paper 2Write a function which accepts a character, ch, and returns 1 if the character is a letter of the alphabet or 0 otherwise. Show how your function would be called.
  8. 6(c)(iii)5 marks· CAPE Computer Science Unit 1 · 2010 · Paper 2Write a function which accepts a character, ch, and returns 1 if the character is present in the string 'CAPECOMPUTERSCIENCE', or 0 if ch is not present.
  9. 5(b)2 marks· CAPE Computer Science Unit 1 · 2011 · Paper 2Give TWO advantages of using a modular approach in programming.
  10. 5(d)15 marks· CAPE Computer Science Unit 1 · 2011 · Paper 2Write a C program that reads the jellybean contest data from 'contest.txt' and outputs to 'winner.txt' the winning guess and member ID code (without using arrays).
  11. 6(a)2 marks· CAPE Computer Science Unit 1 · 2011 · Paper 2Explain the term 'white space'.
  12. 6(b)2 marks· CAPE Computer Science Unit 1 · 2011 · Paper 2Define the term 'debugging'.
  13. 6(c)2 marks· CAPE Computer Science Unit 1 · 2011 · Paper 2Explain why programmers should practise proper indentation.
  14. 5(b)7 marks· CAPE Computer Science Unit 1 · 2012 · Paper 2Write a C function which accepts a positive integer, n, and returns 2^n. State any assumptions made.
  15. 5(c)(i)7 marks· CAPE Computer Science Unit 1 · 2012 · Paper 2Write C code to store the even numbers from 2 (inclusive) to 40 (inclusive) in a file called "num.dat".
  16. 5(c)(ii)5 marks· CAPE Computer Science Unit 1 · 2012 · Paper 2Write C code to read the integers from the file "num.dat" created in (c)(i), add 5 to each integer and print the result on the screen.
  17. 6(a)6 marks· CAPE Computer Science Unit 1 · 2012 · Paper 2Explain THREE ways in which good programming style can be maintained.
  18. 6(b)(i)2 marks· CAPE Computer Science Unit 1 · 2012 · Paper 2Write a declaration for a C struct productRec that can store the record for each product.
  19. 6(b)(ii)1 mark· CAPE Computer Science Unit 1 · 2012 · Paper 2Declare TWO variables, item1 and item2, that have the record structure declared in (b)(i).
  20. 6(b)(iii)2 marks· CAPE Computer Science Unit 1 · 2012 · Paper 2Write C code to put data in the item1 struct declared in (b)(ii) using any values.
  21. 6(b)(iv)3 marks· CAPE Computer Science Unit 1 · 2012 · Paper 2Assuming two productRec structs, item3 and item4, are already loaded with data, write C code to exchange their values.
  22. 5(c)7 marks· CAPE Computer Science Unit 1 · 2013 · Paper 2Write 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.
  23. 6(d)(i)3 marks· CAPE Computer Science Unit 1 · 2013 · Paper 2Write a C declaration for a struct to store a customer record consisting of a customer ID (integer) and customer balance (float).
  24. 6(d)(ii)4 marks· CAPE Computer Science Unit 1 · 2013 · Paper 2Declare two struct variables representing customers Andrew and Jamie, and initialise their fields with the values: Andrew (ID: 1200, Balance: 1000) and Jamie (ID: 1500, Balance: 3000).
  25. 6(d)(iv)3 marks· CAPE Computer Science Unit 1 · 2013 · Paper 2Write C code to interchange the records of Andrew and Jamie.
  26. 5(b)2 marks· CAPE Computer Science Unit 1 · 2014 · Paper 2Explain the role of a 'watch' in programming.
  27. 5(d)15 marks· CAPE Computer Science Unit 1 · 2014 · Paper 2Write 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.)
  28. 6(a)2 marks· CAPE Computer Science Unit 1 · 2014 · Paper 2Explain why indentation is important in programming.
  29. 6(b)2 marks· CAPE Computer Science Unit 1 · 2014 · Paper 2Why is it recommended that comments be used in programming code?
  30. 5(b)2 marks· CAPE Computer Science Unit 1 · 2015 · Paper 2Explain what modular programming is and how it promotes good programming practices.
  31. 5(c)10 marks· CAPE Computer Science Unit 1 · 2015 · Paper 2Write a C program that reads 'testgrades.txt' to count and display the number of students receiving grades A (80-100), B (70-79), C (60-69), and F (<=59), along with the highest overall mark.
  32. 6(c)(i)2 marks· CAPE Computer Science Unit 1 · 2015 · Paper 2Write a declaration for a C struct fruitRec to store a fruit's ID (int), cost price (float), selling price (float), and quantity in stock (int).
  33. 6(c)(ii)1 mark· CAPE Computer Science Unit 1 · 2015 · Paper 2Declare two variables, apple and pear, of type struct fruitRec.
  34. 6(c)(iii)2 marks· CAPE Computer Science Unit 1 · 2015 · Paper 2Write C code to populate the apple struct variable with sample data.
  35. 6(c)(iv)2 marks· CAPE Computer Science Unit 1 · 2015 · Paper 2Assuming two fruitRec variables pine and mango are populated, write C code to swap their cost price and selling price values.
  36. 6(c)(v)3 marks· CAPE Computer Science Unit 1 · 2015 · Paper 2Assuming two fruitRec variables a and b are populated, write C code to compute and display the total expected profit from selling both fruits.