Chapter 1
Chapter 1
1. What is Pseudocode?
• Definition: Pseudocode is a simplified, half-code, half-English textual representation of a
programming algorithm. It is not executed on computers but helps programmers plan and
discuss algorithms.
• Purpose: The main goal is to focus on the algorithm's logic without worrying about
syntax rules of a specific programming language.
• Audience: Useful for programmers, developers, and anyone learning programming
concepts.
2. Characteristics of Pseudocode
• Simplicity: Easy to read and write by humans.
• Language Independence: Not bound by the syntax of any programming language.
• Flexibility: Allows for the expression of algorithms in a way that best communicates the
intended logic.
3. Basic Syntax and Conventions
While pseudocode does not have a strict syntax, some common conventions are often followed:
• Variables: Write in plain English, often avoiding special characters. E.g., totalPrice,
count.
• Operations: Use common mathematical symbols (+, -, *, /) and simple English words
for other operations (AND, OR, NOT).
• Control Structures: Keywords for control structures (e.g., IF, THEN, ELSE, FOR,
WHILE) are capitalized to distinguish them from variables.
4. Common Pseudocode Constructs
4.1. Variables and Assignment
• Declaration: Implicitly done when the variable is first used.
• Assignment: Use the = symbol, e.g., total = 0.
4.2. Input and Output
• Input: READ or INPUT, e.g., READ userName.
• Output: PRINT or WRITE, e.g., PRINT total.
4.3. Conditional Statements
IF condition THEN
statement(s)
ELSE
statement(s)
END IF
4.4. Loops
For Loop:
// Iterate from 1 to N
For i from 1 to N do
// Add the current value of i to the sum
sum = sum + i
EndFor