Programming and Algorithm Execution
Core ideas
Questions present short programs or pseudocode and ask for the output. You must understand variables and types (integer, real, string, boolean), assignment, arithmetic operators (including integer division div/// and remainder mod/%), comparison and logic, and arrays with indexing. Control flow: sequence, conditionals, loops, and simple subroutines.
Traps to watch
- Integer vs. real division:
7 / 2may be 3.5 or 3 depending on type;7 mod 2is 1. - Array indices: know whether the first index is 0 or 1 in the given language/pseudocode.
- String concatenation vs. numeric addition:
"2" + 3may give"23". - Operator precedence:
and/orand comparison order; use parentheses mentally. - Off-by-one in loop bounds and in
for i = a to b(inclusive).
Rule of thumb
Execute the program exactly as written, line by line, tracking every variable. Do not "optimize" or assume intent - the machine does what is written.
Worked example
x = 10
y = 3
q = x div y
r = x mod y
print q, r
10 div 3 = 3, 10 mod 3 = 1, so output is 3 1. If a student computes 10/3 = 3.33, they have used real division and will pick the wrong option.