May/June 2023 Paper 2
1. IDE Debugging Techniques
Q: How can an IDE be used to debug a function like
Calculate()?
A: Breakpoints, single stepping, and variable watch windows can be used to pause execution, step through lines of code one by one, and monitor variable values respectively.
2. Errors in Pseudocode Statements
Q: What is the error in
Index ← STR_TO_NUM(("27") + 2)?
A: Addition between a string and a number is not valid."27"needs to be converted to a number before addition.Q: What is the error in
Index ← STR_TO_NUM(MID("CPE1704TKS", 4, 2))?
A: No error.Q: What is the error in
IF MONTH(ThisDate) > '6' THEN?
A: MONTH() returns an integer, and it is being compared with a string'6'. The comparison should be with a numeric value.
3. Evaluating Boolean Expressions
Q: Evaluate
(Points > 99) OR ActiveifPoints = 75andActive = TRUE.
A: TRUE.Q: Evaluate
(Points MOD 2 = 0) OR ExemptifPoints = 75andExempt = FALSE.
A: FALSE.Q: Evaluate
(Points <= 75) AND (Active OR Exempt)ifPoints = 75,Active = TRUE, andExempt = FALSE.
A: TRUE.Q: Simplify
(Active OR NOT Active) AND NOT Exempt.
A:NOT Exempt.
4. Generating a String of Repeated Characters
Q: Describe the algorithm to generate a string of repeated characters.
A: 1. Input a characterMyChar.
2. Input an integerMyCount.
3. Generate a string withMyCharrepeatedMyCounttimes.
4. Output the string.
5. Data Structures for Storing Customer Information
Q: What data structure is suitable for storing customer information?
A: A record structure, as it allows different types of data (e.g., String, Integer, Date) to be stored under one identifier.
6. Calculation of Points in Different Bands
Q: How are points calculated for store purchases based on spending bands?
A:Identify the appropriate band based on the amount.
For amounts
< $10, multiply by 5.For amounts
$10 to $100, multiply by 7.For amounts
> $100, multiply by 10.Output the number of points.
7. Replace Character in a String
Q: Describe the pseudocode to replace a character in a string.
A:Loop through each character in the string.
If it matches the character to replace, change it to the new character.
Concatenate the new string.
Return the modified string.
8. Waterfall Model Disadvantages
Q: List two disadvantages of the Waterfall Model.
A:No working software until late in the life cycle.
Difficult to adapt to changes in requirements.
9. More Appropriate Model than Waterfall for Dynamic Websites
Q: What is a more suitable development model for a website that may have changing requirements?
A: Iterative or Rapid Application Development (RAD).
10. Beta Testing Description
Q: Describe the purpose of Beta Testing.
A: Conducted by potential users to check if the software works in real-world conditions, identify bugs, and provide feedback for improvements before the final release.
11. Calculating Average Sound Sample Values
Q: How does the procedure
Mix()process sound samples?
A: It calculates the average of each column in a 2D array, ignoring values ≤ 10, and stores the result in a 1D array.
12. Modules for Library Management System
Q: List three program modules for a library system that sends overdue book reminders.
A:GetOverdueLoan(): Identifies overdue books.IdentifyStudent(): Finds the student with the overdue book.SendEmail(): Sends the reminder email.
13. Structure Chart Representation
Q: What does it mean when Module-A calls Module-B, Module-C, and Module-D in a structure chart?
A: Module-A controls the flow and logic of Module-B, Module-C, and Module-D, determining when each one is executed.
14. Pseudocode Module Headers
Q: Write the pseudocode header for a procedure
Sub-Aand a functionSub-B.
A:PROCEDURE Sub-A(Name : STRING, BYREF P2 : BOOLEAN)FUNCTION Sub-B(P1 : REAL) RETURNS REAL
15. File Operations for Stock Control
Q: Which file mode should be used to add new items to
Stock.txt?
A: Append mode, so new data is added to the end of the file without overwriting.
16. Efficient Searching in Ordered Files
Q: How does sorting
Stock.txtbyItemNumimprove search efficiency?
A: It allows for a binary search, reducing the number of comparisons needed to locate an item.