Pascal (Introduction)
Pascal (Introduction)
PROGRAMMING USING
PASCAL
2
1. Program name:
All programs must have a name
Program names must begin with a letter of the
alphabet
Spaces are not allowed in program names
4
Program
Header
Const //declare constants here Constant and Variable
Var //declare variables here declarations
Begin
// place statements inside here. Main of the program
End.
Input values
7
Example:
Readln(x)
Above a value is read into a variable called x.
Output values from variables and constants
8
Example:
Writeln(x)
Above the value which is currently stored in the
variable/constant x will be displayed on the
computer screen.
Output messages to the computer screen.
9
Example:
Writeln(‘hello world’);
The statement above will print HELLO WORLD
on the computer screen.
Writeln / Write
10
Writeln
Prints information in a new line.
Write
Prints information without putting it into a new
line.
Assign values to variables:
11
Example:
x:=9;
Above the value 9 is assigned to a variable called
x.
Assign values to constants
12
Example
X=9;
Above the value 9 is assigned to constant x.