A computer program is a set of instructions written in a programming language that directs a computer to perform a specific task or solve a particular problem. When a program is run, the computer follows these instructions step by step to produce the desired output.
Examples of computer programs:
- A calculator application that performs arithmetic
- A word processor that formats text
- A game that responds to player input
| Term | Definition |
|---|
| Program | A single set of instructions written to perform a specific task |
| Software | A broader term that includes one or more programs, along with documentation and configuration data |
In simple terms, all programs are software, but not all software is a single program. For example, Microsoft Office is software that contains multiple programs (Word, Excel, PowerPoint).
A programmer (also called a developer or coder) is a person who:
- Writes the source code of a program using a programming language
- Tests the program to find errors
- Maintains and updates the program over time
Programmers use languages such as Python, C++, Java, and others to communicate instructions to the computer.
Computers only understand machine language, which consists of binary code — sequences of 0s and 1s. Every instruction a programmer writes in a high-level language (like Python) must eventually be translated into binary for the CPU to execute.
Levels of programming languages:
- Machine Language — Binary (0s and 1s); directly understood by the CPU
- Assembly Language — Uses mnemonics (e.g.,
MOV, ADD); translated by an assembler
- High-Level Language — Human-readable (e.g., Python, C++); translated by a compiler or interpreter
When a program runs, the CPU follows the Fetch-Decode-Execute cycle:
- Fetch — The CPU retrieves the next instruction from memory (RAM)
- Decode — The CPU interprets what the instruction means
- Execute — The CPU carries out the instruction
Programs must be loaded into RAM (main memory) before the CPU can execute them. The program stored on disk is copied into RAM at runtime.
Computer programming is important because it:
- Automates repetitive tasks, saving time and reducing human error
- Solves complex problems that would be impractical to solve manually
- Powers technology — from smartphones and websites to medical equipment and space exploration
- Enables creativity — programmers can build new tools, games, and applications
- Drives the economy — software development is one of the fastest-growing industries worldwide
Before writing actual code, a good programmer plans the solution. This is a key skill in computational thinking.
An algorithm is a step-by-step procedure for solving a problem. It must be:
- Clear — each step is unambiguous
- Finite — it must end after a certain number of steps
- Effective — each step must be achievable
Pseudocode is an informal, plain-language description of an algorithm. It is not actual code — it has no strict syntax rules — but it describes the logic clearly.
Example: Write pseudocode to find the larger of two numbers.
START
INPUT number1
INPUT number2
IF number1 > number2 THEN
PRINT number1, "is larger"
ELSE
PRINT number2, "is larger"
END IF
END
- Helps plan the program before coding
- Makes it easier to spot logical errors early
- Language-independent — can be converted to any programming language
- Useful for communicating ideas to other programmers
- Define the problem — Understand what needs to be solved
- Plan the solution — Write pseudocode or draw a flowchart
- Write the code — Translate the plan into a programming language
- Test the program — Run it with different inputs to check correctness
- Debug and refine — Fix errors and improve the program
- Document — Add comments and write user documentation
- A computer program is a set of instructions for the computer to follow.
- Software is a broader term that includes programs, documentation, and data.
- A programmer writes, tests, and maintains programs.
- Computers understand only binary (machine language); high-level code must be translated.
- The CPU uses the Fetch-Decode-Execute cycle to run programs.
- Pseudocode and algorithms are essential planning tools before writing code.
- Programming is important because it automates tasks, solves problems, and drives technology.