The Pascal programming language does not distinguish between uppercase and lowercase letters. This means you can write variables, functions, and procedures using both uppercase and lowercase letters. Below are detailed insights into keywords and basic syntax in Pascal.
Variable
Variables (variable) are placed within a block starting with the keyword 'var,' followed by variable definitions as follows:
var
A_Variable, B_Variable ... : Variable_Type;
Pascal variables are declared within the code section of a function, meaning they should not be declared within the opening and closing pairs but after defining procedures/functions and before the start keyword. For global variables, they are defined after the program header.
Function (function) / Procedure (procedure)
In Pascal, a procedure establishes instructions to be executed, with no return value, while a function is a procedure with a return value. Definitions for function/procedure are as follows:
Procedure Proc_Name(params...);
Comment
Multi-line comments are enclosed in curly braces and asterisks, denoted as {* ... *}. Pascal allows single-line comments enclosed in curly braces {...}.
{* This is a multi-line comment
And it will extend over several lines. *}
{ This is a single-line comment in Pascal }
Case Sensitivity
The Pascal programming language does not distinguish between uppercase and lowercase letters. This means you can write variables, functions, and procedures in both uppercase and lowercase. For example, variables A_Variable, a_variable, and A_VARIABLE all have significance in Pascal.
Pascal Commands
Pascal programs are constructed from commands. Each command defines a specific task of the program. These tasks can include declarations, assignments, reading data, writing data, program control flow, and more.
For example:
readln(a, b, c);
s := (a + b + c)/2.0;
area := sqrt(s * (s - a)*(s-b)*(s-c));
writeln(area);
Reserved Keywords in Pascal
Commands in Pascal are designed with specific Pascal keywords, known as reserved words. For instance, word (keyword), program (program), input (input), output (output), var, real, begin, readline, writeline, and end are all reserved keywords in Pascal.
Below is a list of reserved keywords available in Pascal.
Character Set and Identifiers in Pascal
The Pascal character set includes:
- All uppercase letters (A-Z).
- All lowercase letters (a-z).
- All digits (0-9).
- Special symbols - + * /: =,. ; () [] = {} and whitespace
Entities in a Pascal program such as variables, constants, types, functions, procedures, and records will have a name or an identifier. An identifier is a sequence of letters and digits, starting with a letter. Special symbols and whitespace are not used in identifiers.
By grasping the fundamental keywords and syntax in Pascal, it is hoped that you will gain a better understanding of this widely used high-level programming language. Share your thoughts with Mytour.