REPRESENTING ALGORITHMS II - PSEUDOCODE
2. Pseudocode Conventions and Standards
Basic Pseudocode Structure
ALGORITHM_NAME
// Header section with algorithm description
BEGIN
// Variable declarations (if needed)
// Input operations
// Processing steps
// Output operations
END
Common Pseudocode Keywords and Conventions
|
Construct |
Pseudocode Keyword |
Example |
|
Algorithm Start |
ALGORITHM, BEGIN |
ALGORITHM CalculateAverage |
|
Algorithm End |
END |
END CalculateAverage |
|
Input |
READ, INPUT, GET |
READ studentName |
|
Output |
PRINT, DISPLAY, WRITE |
PRINT "Hello World" |
|
Assignment |
← or = |
total ← mark1 + mark2 |
|
Conditional |
IF-THEN-ELSE-ENDIF |
IF score >= 50 THEN |
|
Loops |
WHILE-ENDWHILE, FOR-ENDFOR |
WHILE count < 10 DO |
|
Comments |
// or /* */ |
// This is a comment |
Variable Declaration and Usage
- Variables are implicitly declared by their first use
- Use meaningful names (e.g., studentCount instead of sc)
- No need to specify data types in pseudocode
- Example: counter ← 0 or totalMarks ← 0