Programming Fundamentals (Problem Solving, Logic, and Algorithms)
Programming Fundamentals tests the problem-solving chain: understand the problem, design an algorithm or flowchart, code it, then test it. Expect flowchart symbol matching, dry runs of short loops, and classification of errors.
Algorithm and flowchart
A good algorithm is finite, definite (unambiguous steps) and effective, with zero or more inputs and at least one output. Flowchart symbols: oval for start or stop, parallelogram for input or output, rectangle for a process, diamond for a decision, and arrows for flow.
Control structures
Sequence, selection (if, if-else, switch) and iteration (while, do-while, for). A while loop tests before executing, so it may run zero times; a do-while runs at least once. Every loop needs an update that moves the condition toward termination.
Types of error
Syntax errors break language rules and are caught at compile or interpretation time. Logical errors compile but give wrong output, for example using a less-than sign where less-than-or-equal was needed. Run-time errors occur during execution, such as division by zero.
Worked example. Dry run: set sum to 0; for i from 1 to 5, set sum to sum + i. Successive values of sum are 1, 3, 6, 10, 15, so the output is 15. Reasoning: the body executes five times and the final value of sum, not i, is printed.
Traps. A single equals sign assigns; a double equals sign compares. Printing inside a loop produces five lines, not one total. Integer division such as 7/2 gives 3 in C-like languages. The loop header 1 to 5 includes 5, so watch off-by-one counts.