0% found this document useful (0 votes)
20 views30 pages

G 12 - Programming (Pascal and C++)

The document outlines the fundamentals of programming and pseudocode algorithms for Grade 12 students, covering topics such as programming languages, program structure, reserved words, data types, and types of variables. It distinguishes between low-level and high-level languages, explains the roles of compilers and interpreters, and provides examples of simple programs in Pascal and C++. Additionally, it introduces pseudocode as a method for writing algorithms in a structured manner.

Uploaded by

pascal.k.nduba
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views30 pages

G 12 - Programming (Pascal and C++)

The document outlines the fundamentals of programming and pseudocode algorithms for Grade 12 students, covering topics such as programming languages, program structure, reserved words, data types, and types of variables. It distinguishes between low-level and high-level languages, explains the roles of compilers and interpreters, and provides examples of simple programs in Pascal and C++. Additionally, it introduces pseudocode as a method for writing algorithms in a structured manner.

Uploaded by

pascal.k.nduba
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

MON - AUGUST 18, 2025

Programming and
Pseudocode Algorithms

MR MTHENGO F
GRADE 12
OBJECTIVES
• Concept of Programming Language
• Program Structure
• Reserved Words
• Data Types
• Types of Variables
• Simple Programs
• Pseudocode and Algorithms
• Past Paper Exam Questions
Concept of Programming
Language
Definition

A programming language is a structured way of

giving instructions to a computer. Since computers

only understand binary (0s and 1s), we use a

programming language as a bridge between

humans and machines.


Categories of Programming
Languages
1. Low-Level Languages

Machine Language → written in binary (0s


and 1s). Very fast but difficult for humans.

Assembly Language → uses mnemonics


(like MOV A, 5) and requires an assembler.
1. High-Level Languages

Closer to English, easy to understand.

Require translators (compiler or


interpreter).
Examples: Pascal, C++, Python, Java.
Compilers vs Interpreters

Compiler: Translates whole program at


once (C++, Pascal).
Interpreter: Translates line by line (Python,
BASIC).
“Pascal and C++ are high-level, compiled programming languages.”
Program Structure
A good program must follow a clear structure. In

both Pascal and C++, the structure can be broken

into:
1. Program Header / Name

Identifies the program.

Pascal: Program MyProgram;

C++: #include <iostream> then using


namespace std;
2. Declaration Section
Where variables and constants are declared.

Pascal:

• Var

• age: Integer;

• name: String;

C++:

• int age;

• string name;
3. Beginning of Program

Pascal: Begin

C++: int main() {


5. Ending

Pascal: End.

C++: return 0; }
In Pascal, the final End. must have a full stop; missing it is a common error.
Reserved Words
Definition

Reserved words (or keywords) are words that have

special meaning in a language and cannot be

used as identifiers.
Examples

Pascal: Program, Begin, End, Var, If,


Then, Else, For, While, Do.

C++: int, float, if, else, while, for,


return, class, public.
Data Types
User-defined Data Types
Created by the programmer.
Pascal:
Type
 Age = Integer;
 StudentName = String[30];
C++:
typedef unsigned int Age;
struct Student {
 string name;
 int age;
};
Types of Variables
User-defined Data Types
Integer → whole numbers (e.g., 4, -9).
• Pascal: Var age: Integer;
• C++: int age;
Real (Float) → decimal numbers (e.g., 3.14).
• Pascal: Var price: Real;
• C++: float price;
Character → single letters (‘A’, ‘Z’, ‘1’).
• Pascal: Var grade: Char;
• C++: char grade;
Boolean → logical values (TRUE/FALSE).
• Pascal: Var status: Boolean;
• C++: bool status;
Simple Programs
Pascal Example – Sum of Two Numbers

Program SumNumbers;
Var
num1, num2, sum: Integer;
Begin
Write('Enter first number: ');
Readln(num1);
Write('Enter second number: ');
Readln(num2);
sum := num1 + num2;
Writeln('The sum is: ', sum);
End.
C++ Example – Sum of Two Numbers
#include<iostream>
using namespace std;

int main() {
int num1, num2, sum;
cout << "Enter first number: ";
cin >> num1;
cout << "Enter second number: ";
cin >> num2;
sum = num1 + num2;
cout << "The sum is: " << sum << endl;
return 0;
}
Pseudocode and Algorithms
Pseudocode

A way of writing algorithms using structured


English-like statements.

Not tied to any programming language.


Example (Add Two Numbers):

BEGIN

INPUT num1, num2

sum ← num1 + num2

OUTPUT sum

END
Algorithm

Step-by-step instructions to solve a problem.

Must be finite, clear, and effective.

 First design an algorithm, then write it as


pseudocode, then convert to Pascal/C++ code.
END OF LESSON

You might also like