AKU-CS · Topic 2 of 4

Programming Basics

Introduction to algorithms, pseudocode, and flowcharts for solving biological problems.

~5Minutes
7Key points
5Questions
All Computer Studies topics

Study path

Learn it, recall it, then prove it

01 · Understand

Read the explanation and work through each example.

02 · Recall

Close the notes and explain the main idea yourself.

03 · Practise

Attempt the quiz, then revisit only missed concepts.

Programming Basics — AKUEB Computer Studies (SSC)

1. What is Programming?

Programming (or coding) is the process of writing a set of instructions for a computer to follow. These instructions are written in a programming language that the computer can understand and execute.

A program is a sequence of instructions that solves a particular problem or performs a specific task.

The problem-solving process:

  1. Understand the problem — what input do you have? What output do you need?
  2. Plan the solution — design your algorithm (steps to solve it)
  3. Write the code — translate the algorithm into a programming language
  4. Test and debug — run the program and fix errors
  5. Maintain — update and improve as needed

2. Algorithms

An algorithm is a step-by-step set of instructions to solve a problem. It must be:

  • Unambiguous — each step is clear with only one interpretation
  • Finite — it must end after a fixed number of steps
  • Correct — it must produce the right output for all valid inputs

Example algorithm — making a cup of chai:

  1. Pour water into kettle
  2. Boil water
  3. Add tea leaves and sugar
  4. Simmer for 2 minutes
  5. Add milk
  6. Strain into cup
  7. Serve

3. Flowcharts

A flowchart is a visual representation of an algorithm. It uses standard symbols:

SymbolShapeUsed for
TerminalOval/rounded rectangleStart / End
ProcessRectangleCalculation or action (e.g., Add A + B)
DecisionDiamondYes/No question (e.g., Is A > B?)
Input/OutputParallelogramInput a value / Display a result
ArrowLine with arrowFlow of control

Example — flowchart for checking if a number is even:

  1. START
  2. INPUT number
  3. Is number ÷ 2 remainder = 0? (Diamond — Yes/No)
  • YES → OUTPUT "Even" → END
  • NO → OUTPUT "Odd" → END

4. Pseudocode

Pseudocode is a way of writing algorithms in plain, structured English — it is not actual code but it follows a logical structure. Different exam boards have slightly different conventions; AKUEB uses a readable, structured format:

BEGIN
  INPUT number
  IF number MOD 2 = 0 THEN
    PRINT "Even"
  ELSE
    PRINT "Odd"
  ENDIF
END

Key pseudocode constructs:

Sequence: Instructions run one after another in order.

INPUT length
INPUT width
area ← length * width
PRINT area

Selection (IF-THEN-ELSE): Executes different instructions based on a condition.

IF score >= 50 THEN
  PRINT "Pass"
ELSE
  PRINT "Fail"
ENDIF

Iteration (loops): Repeats instructions.

FOR count ← 1 TO 5
  PRINT count
NEXT count

5. Programming Concepts

Variables: Named storage locations that hold data. The value can change during the program.

  • Example: score ← 0 declares a variable called score with starting value 0.

Constants: Like variables, but the value NEVER changes during the program.

  • Example: TAX_RATE ← 0.17 (Pakistan's GST rate — stays fixed in the program)

Data types:

TypeWhat it storesExample
IntegerWhole numbers42, -7, 0
Real/FloatDecimal numbers3.14, 9.8
StringText / characters"Ahmed", "Karachi"
BooleanTrue or False onlyTrue, False

Operators:

  • Arithmetic: +, -, *, / (divide), MOD (remainder), DIV (integer division)
  • Comparison: =, <, >, <=, >=, <> (not equal)
  • Logical: AND, OR, NOT

6. Types of Programming Errors

Syntax error: The code breaks the grammar rules of the language.

  • Example: Forgetting to close a bracket — PRINT("hello" — the compiler rejects it.

Logic error: The program runs without crashing but produces wrong results.

  • Example: Writing area ← length + width instead of area ← length * width — the program runs but gives wrong answers.

Runtime error: The program crashes while running due to an impossible operation.

  • Example: Dividing by zero or trying to open a file that does not exist.

7. Trace Tables

A trace table is used to manually track the values of variables as an algorithm executes — step by step. This helps detect logic errors.

StepnumberremainderOutput
INPUT 66
remainder ← 6 MOD 260
IF 0 = 060"Even"

Quick revision infographic

Computer Studies · Quick revision

Programming Basics

Key concepts

  1. 01An algorithm must be unambiguous, finite, and correct — it is the plan before the code.
  2. 02Flowchart symbols: oval=start/end, rectangle=process, diamond=decision, parallelogram=input/output.
  3. 03Three fundamental constructs: sequence (one after another), selection (IF-THEN-ELSE), iteration (loops).
  4. 04Variables hold data that can change; constants hold data that never changes during execution.
  5. 05Four data types to know: integer, real/float, string, boolean.
  6. 06Three error types: syntax (grammar rule broken), logic (runs but wrong output), runtime (crashes mid-execution).

Formulas to know

Flowchart symbols: oval=start/end, rectangle=process, diamond=decision, parallelogram=input/output.
Algorithm for a Mobile Top-Up System (Jazz, Telenor, Zong)

Pakistani students interact daily with automated systems that follow algorithms: mobile top-up via SMS (e.g., texting *123*amount# on Jazz). The algorithm: INPUT mobile number and amount → VERIFY number exists in database → CHECK account balance >= amount → IF yes: DEDUCT balance, CREDIT recipient, SEND confirmation SMS → ELSE: SEND 'insufficient balance' message. This maps directly to programming concepts: input/output, variables (balance, amount), selection (IF balance >= amount), and sequence. Students can trace through this algorithm in a trace table using their own phone numbers and top-up amounts.

SeekhoAsaan.com · Free revisionProgramming Basics

Test your knowledge.

5 explained questions. Har answer ke baad reasoning foran milegi.

2 Beginner1 Intermediate2 Advanced
Start 5-question quiz