3. Programming Concepts
Higher Secondary · Computer Applications / Commerce

Programming Concepts

Computers have no common sense — they need precise, step-by-step instructions. This chapter walks through how a real-world problem becomes a working program: planning it as an algorithm and flowchart, coding it, translating it, debugging it, testing it, and documenting it. Try the live calculator below.

"The function of a good software is to make the complex appear to be simple." — Edward Bernard
3.3 · Live Tool

Student Result Calculator

This is the running example used throughout the chapter. Enter marks (out of 100) for six subjects and watch the total and percentage calculate live — exactly what the algorithm, flowchart, and Python code on this page describe.

Total & Percentage

● live
Subjects entered
0 / 6
Total (out of 600)
—
Percentage
—
Result
—
Only numeric marks from 0–100 are accepted per subject. This mirrors Step 2–6 of the Student Result Management algorithm: Input → Total = M1+M2+M3+M4+M5+M6 → Percentage = (Total / 600) × 100 → Display.
3.3

Phases in Programming

Writing a program is like constructing a building — you need a plan before you start. Programming follows a clear, repeatable cycle from problem to finished product, combining analytical thinking (breaking a problem into parts) and creative thinking (finding smart ways to solve them).

Problem Identification1

Define the gap between the current state and the desired result.

Algorithm & Flowchart2

Design the logical plan in plain language and as a diagram.

Coding3

Translate the plan into a programming language (source code).

Translation4

Convert source code into machine-readable object code.

Debugging5

Find and correct syntax, logical, and run-time errors.

Execution & Testing6

Run the program and verify its results under various conditions.

Documentation7

Record how the program works, for users and future developers.

Two Kinds of Thinking

Analytical: break the big problem down. Creative: find smart ways to solve the parts.

Worked example used throughout this chapter
Develop a program to calculate and display the total marks and percentage of mark of a student based on scores in six subjects.
3.3.2 (a)

Algorithms

An algorithm is a step-by-step procedure to solve a problem — like a recipe, or directions to a friend's house. The term comes from Muhammad Ibn Musa Al-Khwarizmi, a 9th-century Persian mathematician often called the father of algebra.

Guidelines for Writing Algorithms

Storing Information

Give data unique names (like Marks, Age, Total) so it can be stored and found again.

Writing the Steps

Input: Input, Read, Get. Process: Calculate, Add, Set. Output: Print, Display, Show.

General Rules

Every algorithm has a Start and Stop, uses clear unambiguous steps, and must always end.

Example — Area and perimeter of a rectangle
Step 1: Start Step 2: Input Length, Breadth Step 3: Perimeter = 2 × (Length + Breadth) Step 4: Area = Length × Breadth Step 5: Print Perimeter, Area Step 6: Stop
Applied example — Student Result Management
Step 1: Start Step 2: Input M1, M2, M3, M4, M5, M6 Step 3: Total = M1 + M2 + M3 + M4 + M5 + M6 Step 4: Max = 600 Step 5: Percentage = (Total / Max) × 100 Step 6: Display Total, Percentage Step 7: Stop

Benefits of Using Algorithms

Efficient Problem-Solving

Breaks large problems into smaller, easy-to-manage steps.

Improved Accuracy

A correct, step-by-step algorithm reduces the chance of mistakes.

Scalability

Logic that works for one class can scale to an entire school.

Foundation of Programming

Acts as the blueprint before writing code in Python, C++, etc.

3.3.2 (b)

Flowcharts

A flowchart is a pictorial representation of an algorithm, using standard geometric shapes connected by arrows to show the direction of flow.

SymbolNameDescription
start / end
Start / End (Terminator) Marks the beginning or end of a process.
process
Process / Action Step Represents a process, task, or action to be performed.
Yes/No
Decision Point Indicates a decision or branching point (Yes/No or True/False).
I/O
Input / Output Represents input to or output from a process (user input, data display).
↓ ↑ → Flow line Shows the direction of flow between steps.
⭕ Connector / Link Connects or links different sections of a flowchart.

Advantages & Limitations

Better Communication

A visual map of the program is easier to explain than lines of code.

Effective Analysis

Helps spot logical errors and dead ends before writing any code.

Time-Consuming

Drawing a neat, correct flowchart takes longer than writing text.

Difficult to Modify

A logic change often means redrawing the whole diagram.

3.3.2

Flow of Control

The path through which a computer takes instructions is the flow of control. Real-world problems need more than a straight list of steps — three primary types handle choice and repetition.

Sequential (The Straight Line)

Every instruction executes in the exact order written, top to bottom — like reading a book, or baking a cake step by step.

StartInputProcessOutput

Branching / Selection (The Crossroad)

The program checks a condition and follows one of two paths — like a traffic light. Represented with If... Then... Else logic.

IfTrue → Path A

Iteration / Looping (The Cycle)

A set of instructions repeats while a condition remains true — like climbing a flight of stairs, one step at a time.

RepeatWhile A ≤ 10

Example — Highest of two scores (Branching)

If M1 > M2, then Go to Step 4 else Goto Step 5.

Step 1: Start
Step 2: Input M1, M2
Step 3: If M1 > M2, then Go to Step 4 else Goto Step 5
Step 4: Print "M1 is higher". Goto Step 6
Step 5: Print "M2 is higher"
Step 6: Stop
3.3.3 – 3.3.4

Coding & Translation

Computers understand only Machine Language (binary 0s and 1s). High-Level Languages like Python bridge human language and machine code — the instructions we write are called Source Code, and a Language Translator converts it into machine-readable Object Code.

Python source code — Student Result Management
m1 = int(input("Enter Mark 1: ")) m2 = int(input("Enter Mark 2: ")) m3 = int(input("Enter Mark 3: ")) m4 = int(input("Enter Mark 4: ")) m5 = int(input("Enter Mark 5: ")) m6 = int(input("Enter Mark 6: ")) total = m1 + m2 + m3 + m4 + m5 + m6 max_marks = 600 percentage = (total / max_marks) * 100 print("Total Marks =", total) print("Percentage =", percentage)

Compiler vs Interpreter

AspectCompilerInterpreter
TranslationTranslates the whole program at onceTranslates and executes line by line
Object codeGenerates a separate object code fileDoes not generate an object code file
ErrorsScans the entire code and lists all errors at the endStops execution immediately when the first error is found
Example languagesC, C++Python, JavaScript
3.3.5 – 3.3.7

Debugging, Execution & Documentation

An error in a program is historically called a Bug. Debugging is a continuous process of identifying, locating, and correcting bugs — the programmer acts like a doctor diagnosing the program.

Syntax Error

Mistakes in the rules (grammar) of the language that prevent the program from running — e.g. typing prnt instead of print. Caught during translation.

Logical Error

Mistakes in the logic that make the program give the wrong result without crashing — e.g. forgetting brackets in a formula. Found during testing.

Run-time Error

Mistakes that happen while the program is running, causing it to stop suddenly — e.g. dividing by zero. Triggered by unexpected input.

Execution and Testing

Execution is simply running a program to process data. Testing is the intentional process of checking that program for errors — normal values, boundary values (0 or 100), and invalid input are all tried before a program is considered complete.

Documentation

Internal Documentation

Comments written directly in the source code to explain logic to other programmers.

External Documentation

User and technical manuals that provide installation and usage guides for non-programmers.

3.4

Programming Paradigms

A programming paradigm is a fundamental style of programming that guides how the programmer thinks about and structures code — there is no single "correct" way to write a program.

Procedure Oriented Programming (POP)C, Pascal

Treats a program like a step-by-step recipe, broken into procedures executed from top to bottom. Easy to organise, but data shared across the whole program can be risky for complex projects.

Object Oriented Programming (OOP)Python, Java, C++

Models software after real-world entities as Objects, bundling Data (attributes) and Methods (actions) together. Hides data to prevent errors — effective for complex systems, though it takes more initial setup.

Try Yourself

Quick Recap

Tap a question to reveal the answer.

Who is known as the father of algebra and the concept of algorithms?

Muhammad Ibn Musa Al-Khwarizmi, a Persian mathematician who lived around 820 AD.

Which symbol in a flowchart represents a decision or branching point?

The Diamond (Rhombus).

What is an algorithm?

A step-by-step procedure to solve a problem, written in plain language before any code is written — it must have a clear Start and Stop, unambiguous steps, and always terminate.

What is the difference between a Compiler and an Interpreter?

A compiler translates the entire source program at once into a separate object code file and lists all errors at the end. An interpreter translates and executes line by line, generates no separate object code, and stops at the first error.

"Division by Zero" — what type of error is this?

A Run-time Error — the code has no syntax or logical flaw, but crashes when it meets an impossible operation during execution.

What is the difference between execution and testing of a program?

Execution is simply running the program to process data. Testing is the intentional process of checking the program for errors by verifying its results under different conditions — normal, boundary, and invalid input.

Why is Documentation important for the maintenance of software?

It acts as a memory aid for the original programmer, enables teamwork by letting others understand the code without constant explanation, and ensures future developers can maintain or upgrade the system.

Compare procedural and object oriented programming paradigms.

Procedural (POP) breaks a program into a sequence of procedures acting on shared data — simple but risky for large projects. Object Oriented (OOP) bundles data and methods into self-contained objects that model real-world entities, which is safer and more scalable for complex systems.