May/June 2023 Paper 2

1. IDE Debugging Techniques

  1. 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

  1. 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.

  2. Q: What is the error in Index ← STR_TO_NUM(MID("CPE1704TKS", 4, 2))?
    A: No error.

  3. 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

  1. Q: Evaluate (Points > 99) OR Active if Points = 75 and Active = TRUE.
    A: TRUE.

  2. Q: Evaluate (Points MOD 2 = 0) OR Exempt if Points = 75 and Exempt = FALSE.
    A: FALSE.

  3. Q: Evaluate (Points <= 75) AND (Active OR Exempt) if Points = 75, Active = TRUE, and Exempt = FALSE.
    A: TRUE.

  4. Q: Simplify (Active OR NOT Active) AND NOT Exempt.
    A: NOT Exempt.


4. Generating a String of Repeated Characters

  1. Q: Describe the algorithm to generate a string of repeated characters.
    A: 1. Input a character MyChar.
    2. Input an integer MyCount.
    3. Generate a string with MyChar repeated MyCount times.
    4. Output the string.


5. Data Structures for Storing Customer Information

  1. 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

  1. Q: How are points calculated for store purchases based on spending bands?
    A:

    1. Identify the appropriate band based on the amount.

    2. For amounts < $10, multiply by 5.

    3. For amounts $10 to $100, multiply by 7.

    4. For amounts > $100, multiply by 10.

    5. Output the number of points.


7. Replace Character in a String

  1. Q: Describe the pseudocode to replace a character in a string.
    A:

    1. Loop through each character in the string.

    2. If it matches the character to replace, change it to the new character.

    3. Concatenate the new string.

    4. Return the modified string.


8. Waterfall Model Disadvantages

  1. Q: List two disadvantages of the Waterfall Model.
    A:

    1. No working software until late in the life cycle.

    2. Difficult to adapt to changes in requirements.


9. More Appropriate Model than Waterfall for Dynamic Websites

  1. 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

  1. 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

  1. 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

  1. Q: List three program modules for a library system that sends overdue book reminders.
    A:

    1. GetOverdueLoan(): Identifies overdue books.

    2. IdentifyStudent(): Finds the student with the overdue book.

    3. SendEmail(): Sends the reminder email.


13. Structure Chart Representation

  1. 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

  1. Q: Write the pseudocode header for a procedure Sub-A and a function Sub-B.
    A:

    • PROCEDURE Sub-A(Name : STRING, BYREF P2 : BOOLEAN)

    • FUNCTION Sub-B(P1 : REAL) RETURNS REAL


15. File Operations for Stock Control

  1. 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

  1. Q: How does sorting Stock.txt by ItemNum improve search efficiency?
    A: It allows for a binary search, reducing the number of comparisons needed to locate an item.