SH

COMPX101-25A Exam Info and Revision

2025 A Trimester Examinations

  • Department: Computer Science

  • Paper Title: Introduction to Programming

  • Time Allowed: Three Hours

  • Number of Questions in Paper: 33

  • Number of Questions to be Answered: 33

  • Value of Each Question:

    • Section A: 20 marks, 1 mark each

    • Section B: 60 marks, 10 marks each

    • Section C: 20 marks, 2 to 4 marks each

  • Total Marks: 100

  • General Instructions: Answer ALL 20 questions in Section A and ALL 6 questions in Section B and ALL 7 questions in Section C

  • Special Instructions:

    • Answer SECTION A on the Multi-choice Answer Sheet provided. This answer sheet must be tied inside the back cover of your answer booklet.

    • Answer SECTION B and SECTION C in the Answer Booklet provided.

  • Calculators Permitted: No

Section A: Multiple Choice

  • 20 multiple-choice questions, to be answered on multi-choice answer sheet provided, worth 1 mark each

  • Answer all questions by selecting the “most correct” answer

  • The questions test:

    • Code understanding (approx. 70% of questions)

    • Knowledge of programming concepts and C# syntax

    • Knowledge of number conversion

    • Knowledge of computer science concepts and terminology

  • You will need to know about C# concepts such as variable types, scope of variables, operations on variables, loops, selection statements, Boolean logic, random number generation, methods, arrays, and lists, basic computer terminologies such as CPU, RAM, OS, Bit, Byte, IDE etc.

Section B: Question 21

  • Topic: Calculations (10 marks)

  • Scenario: A GUI application that gets input from a user and performs a calculation based on this input.

  • Two questions, (a) and (b), worth four and six marks respectively.

  • First question: Write pseudo code for processing the input, handling input errors, and performing the calculation.

  • Second question: Write C# code for the pseudo code.

Question 1: Pseudo Code

  • Processing the input:

    • Declare variables.

    • Get the input from the textbox controls.

  • Handling input errors:

    • Use try and catch block.

  • Performing the calculation:

    • Use arithmetic operations: (+, -, *, /, %).

    • Declare variables to store the results.

Question 2: C# Code

  • Processing the input:

    • Declare variables.

      • Types of variables: int, double, decimal.

      • Constant or variable: const.

    • Get the input from the textbox controls.

      • textbox.Text (string type).

      • Parse string type to corresponding variable types: string to int, double, decimal.

      • Int.Parse, Double.Parse, Decimal.Parse.

  • Handling input errors:

    • Use try and catch block.

      • Example:

try{
  // Code that might throw an exception
}
catch(Exception ex){
  MessageBox.Show(ex.Message);
}
  • Performing the calculation:

    • Use arithmetic operations: (+, -, *, /, %).

    • Declare variables to store the results.

      • Consider the number of variables needed.

      • Variable types: int, double, decimal.

Section B: Question 22

  • Topic: Selection (10 marks)

  • This question tests your understanding of selection statements and the logic implemented in them.

  • Four questions: the first two questions, and the fourth one, are worth 2 marks each; the third question is worth 4 marks.

  • The first two questions test understanding of a given method that contains a complex if statement in C#.

  • The last two questions ask for modifications of the code to a) fix the code to produce the correct output, and b) extend the range of input that can be processed.

Examples of if Statements and Expected Outputs

Example 1
string message = “”;
if (score < 50){
  message = “Fail”;
}
else{
  message = “Good”;
}
MessageBox.Show(message);
  • What is the output message if score is 48? (Fail)

  • What is the output message if score is 50? (Good)

  • What is the output message if score is 78? (Good)

  • What is the output message if score is 85? (Good)

Example 2

```csharp
string message = “”;
if (score < 50){ message = “Fail”; } if (score >= 80){
message = “Excellent”;
}
else{
message =