FAC1003 Exam Leaks 2025-2026
[!warning] Sources Combined
- Adian Sani — lecture slides captured during revision session
- Student revision notes — WhatsApp-forwarded exam tips (slide image)
Covers 1D and 2D arrays ONLY — no searching/sorting.
Exam Format
| Part | Type | Questions | Marks | Total |
|---|---|---|---|---|
| Part A | Conceptual (T/F, fill blanks, identify errors) | Q1, Q2 | 12 marks each | 24 marks |
| Part B | Write full C++ code | Q3–Q6 | 14 marks each | 56 marks |
| Total | 80 marks |
Exam Strategy & Grading
[!tip] Per-Line Marking Scheme
- Each line of code = 1 mark
- Boilerplate lines (
#include <iostream>,using namespace std;,int main(),return 0;) = ½ mark each- Comments = NO marks — don't waste time writing them
- Semicolons won't be strictly penalized if missed
Code Length Strategy
Make sure your code is more than 14 lines even if the logic is wrong, because each line carries marks.
Lecture Coverage
L19–L32: Mostly covered in Part B (coding questions)
Priority Topics — What's Coming Out
✅ Definitely Coming Out
1. Pointers & References — VERY VERY IMPORTANT
[!tip] Key Distinction
- Pointer: uses
*(asterisk) for dereference,&(ampersand) for address-of- Reference/Call by Reference: uses
&(single ampersand) in parameter declaration
- Recognize code form: pointer vs reference
- Pointer:
*for dereference,&for address-of - Call by reference:
&in parameter declaration - Part A AND Part B will test pointers AND references
Swap with Reference — MEMORIZE:
void swap(int &a, int &b) {
int t = a;
a = b;
b = t;
}
Full swap program:
#include <iostream>
using namespace std;
// (i) Function prototype with reference parameters
void swap(int &x, int &y);
int main() {
int a = 10, b = 20;
// (ii) Function call to swap values
swap(a, b);
cout << "After swap: a = " << a << ", b = " << b << endl;
return 0;
}
// (iii) Function definition
void swap(int &x, int &y) {
int temp = x;
x = y;
y = temp;
}
Pointer Code Pattern:
int* ptr; // Pointer declaration
ptr = &var; // Address-of operator
*ptr = 10; // Dereference
Reference/Call-by-Reference Pattern:
void func(int &x, int &y); // Reference parameters
func(a, b); // Call — modifies original
2. Functions — DEFINITELY COMING OUT
Functions emphasized for organization and making code more structured.
Void vs Non-Void Functions:
| Type | Return | Use Case | Example |
|---|---|---|---|
| Void | No return value | Actions, displaying output | void displayMessage() |
| Non-Void | Returns a value | Calculations, processing | int calculateFactorial(int n) |
[!important] Non-void functions MUST have
returnstatement with a value.
Example fill-in-the-blanks (typical Part A):
#include <iostream>
using namespace std;
// (i) Function PROTOTYPE
void displayMessage();
int main() {
// (ii) Function CALL
displayMessage();
return 0;
}
// (iii) Function DEFINITION
void displayMessage() {
// (iv) Display output
cout << "Hello World!" << endl;
}
Function Prototype — VERY IMPORTANT:
- Just declares the function signature before its first use
- Must match definition in type and order of parameters
// Prototype (declaration)
returnType functionName(parameterList);
// Definition (implementation)
returnType functionName(parameterList) {
// body
}
3. Recursion vs Iteration — MUST DIFFERENTIATE
[!warning] Exam Strategy Most likely they'll ask to use recursion AND iteration in the SAME question.
Factorial — Recursion (MEMORIZE):
int factorial(int n) {
if (n == 0 || n == 1) // Base case
return 1;
else
return n * factorial(n - 1); // Recursive call
}
Factorial — Iteration (MEMORIZE):
int factorial(int n) {
int result = 1;
for (int i = 1; i <= n; i++) {
result *= i;
}
return result;
}
Factorial and Sum of Factorial — COMING OUT
Complete program for factorial with display:
#include <iostream>
using namespace std;
// Subfunction 1: Recursive calculation (NON-VOID)
int calculateFactorial(int n) {
if (n == 0 || n == 1)
return 1;
return n * calculateFactorial(n - 1);
}
// Subfunction 2: Display function (VOID)
void displayResult(int n, int result) {
cout << "Factorial of " << n << " = ";
for (int i = 1; i <= n; i++) {
cout << i;
if (i < n)
cout << " x ";
}
cout << " = " << result << endl;
}
int main() {
int num;
cout << "Enter a positive integer: ";
cin >> num;
int factorial = calculateFactorial(num);
displayResult(num, factorial);
return 0;
}
Fibonacci — MEMORIZE THIS:
int fibonacci(int n) {
if (n <= 1)
return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
4. Loops
- Know all three:
do-while,while,for break— commonly usedcontinueandgoto— rarely used
5. Arrays (1D and 2D)
- Know how to use 1D and 2D arrays
- 3D arrays — NOT in exam (no sign of it)
- Basic array usage, not extensive searching/sorting
6. Scope of Variables
| Scope | Where Declared | Lifetime |
|---|---|---|
| Local | Inside a block/function | Only inside that block |
| Global | Outside all functions | Entire program |
| Static | Inside function, retains value | Entire program run |
int globalVar = 5; // Global — accessible everywhere
void demo() {
int localVar = 10; // Local — only in demo()
static int staticVar; // Static — keeps value between calls
staticVar++;
}
7. Dynamic Memory Allocation
- Uses
newkeyword - For creating arrays at runtime
int* arr = new int[size]; // Dynamic array
// ... use array ...
delete[] arr; // Don't forget to free memory
8. Vectors ⭐
VERY IMPORTANT for the coding part. Know how to use vector for array operations.
9. Encapsulation (Conceptual Only)
Know the meaning, definition and usage of the 4 encapsulation concepts. No coding required.
❓ Maybe Coming Out
| Topic | Notes |
|---|---|
| Passing and returning arrays | Question might ask for static array, dynamic array, or vector |
| Sum of factorial (non-void) | Could appear as a variation |
❌ NOT in Exam
| Topic | Reason |
|---|---|
| Searching & sorting algorithms | Confirmed not tested |
| Strings (extensively) | Basic string array possibly ok |
| Time complexity | NOT IN EXAM |
| Constructors & destructors | NOT included |
| 3D arrays | No sign of it |
| Advanced/complex array operations | Not expected |
Part A Sample — TRUE/FALSE
| No | Statement | Answer |
|---|---|---|
| i | A function can be called multiple times from the main() function |
TRUE |
| ii | The function prototype must include the function's body | FALSE |
| iii | The sqrt() function requires the inclusion of <cmath> library |
TRUE |
| iv | The flow of a program always starts from the called function before the main() function |
FALSE |
| v | Function parameters listed in the prototype must match the definition in type and order | TRUE |
Key Distinctions (Quick Reference)
| Concept | Key Difference |
|---|---|
| Void vs Non-Void | Void = no return, does action. Non-void = returns value, needs return |
| Recursion vs Iteration | Recursion = function calls itself with base case. Iteration = uses loop |
| Pointer vs Reference | Pointer: * to deref, & to address. Reference: & in param declaration |
| Pass by Value vs Pass by Reference | Value = copy. Reference = modifies original |
Flowchart Elements
Sample program flow for discount calculation:
Start
↓
Input data
↓
Check condition (amount > 100)
↓
Calculate discount
↓
Calculate final amount
↓
Display output
↓
End
Key functions in structured programs:
calculateDiscount()— non-void, returnsdoubledisplayBill()— void, takes data by value, formats output