COS1511 May/Jun 2018 exam paper — questions
The paper, as written
Every question, by topic
Question 1.1 · Functions and parameters · 2 marks
Suppose the following declarations appear in the main function of a C++ program: bool register; char documents, paid; int sNumber. Suppose also that the function header bool registerStudent(int sNumberP, char documentsP, char paidP) is given. Which of the options below is a correct calling statement of the function registerStudent in the main function?Show the full question
Question 1.2 · Functions and parameters · 2 marks
Suppose the following declarations appear in the main function of a C++ program: string dayOfWeek; int productCode, number; float discount. Suppose also that the function header void calcDiscount(float & discountP, int productCodeP, int numberP, string dayOfWeekP) is given. Which of the options below is a correct calling statement of the function calcDiscount in the main function?Show the full question
Question 1.3 · Functions and parameters · 2 marks
Suppose the following declarations appear in the main function of a C++ program: int number; float cost, markup, discount. Suppose further that the following calling statement appears in the main function: calcFinal(67.50, markup, discount, 5). Which of the options below is a correct function header for the function calcFinal?Show the full question
Question 1.4 · Code tracing and variable diagrams · 2 marks
Consider the following C++ code segment. What value will newval have after this code has been executed? int var1 = 5; int var2 = 10; int newval; if (var1 * 2 >= var2) newval = 5 + 2 * var2; else if (var2 < var1) newval = var2 - var1 * 2; else newval = var1;Show the full question
Question 1.5 · Code tracing and variable diagrams · 2 marks
Suppose the input value for a is 5. What is the value of a after the following C++ code has been executed? int a; cin >> a; switch (a) { case 1: a += 3; case 3: a = a * 3; break; case 5: a = ++a + 10; case 6: a /= 2; default: a = a + 1; }Show the full question
The full Spot Map and the marks by year — and this paper’s scan.