Category: 06. Pascal
-
Variable Scope
A scope in any programming is a region of the program where a defined variable can have its existence and beyond that variable cannot be accessed. There are three places, where variables can be declared in Pascal programming language − Let us explain what are local and global variables and formal parameters. Local Variables Variables that are declared inside…
-
Procedures
Procedures are subprograms that, instead of returning a single value, allow to obtain a group of results. Defining a Procedure In Pascal, a procedure is defined using the procedure keyword. The general form of a procedure definition is as follows − A procedure definition in Pascal consists of a header, local declarations and a body of the procedure. The procedure header consists of the keyword procedure and…
-
Functions
Subprograms A subprogram is a program unit/module that performs a particular task. These subprograms are combined to form larger programs. This is basically called the ‘Modular design.’ A subprogram can be invoked by a subprogram/program, which is called the calling program. Pascal provides two kinds of subprograms − Functions A function is a group of statements that…
-
Loops
There may be a situation, when you need to execute a block of code several number of times. In general, statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on. Programming languages provide various control structures that allow for more complicated execution paths. A loop…
-
Decision Making
Decision making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false. Following is the…
-
Operators
An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. Pascal allows the following types of operators − Let us discuss the arithmetic, relational, Boolean and bit operators one by one. We will discuss the set operators and string operations later. Arithmetic Operators Following table shows all the arithmetic…
-
Constants
A constant is an entity that remains unchanged during program execution. Pascal allows only constants of the following types to be declared − Declaring Constants Syntax for declaring constants is as follows − The following table provides examples of some valid constant declarations − Real type constant Sr.No Constant Type & Examples 1 Ordinal(Integer)type constantvalid_age…
-
Data Types
Data types of an entity indicates the meaning, constraints, possible values, operations, functions and mode of storage associated with it. Integer, real, Boolean and character types are referred as standard data types. Data types can be categorized as scalar, pointer and structured data types. Examples of scalar data types are integer, real, Boolean, character, subrange…
-
Basic Syntax
You have seen a basic structure of pascal program, so it will be easy to understand other basic building blocks of the pascal programming language. Variables A variable definition is put in a block beginning with a var keyword, followed by definitions of the variables as follows: Pascal variables are declared outside the code-body of the function…
-
Program Structures
Before we study basic building blocks of the Pascal programming language, let us look a bare minimum Pascal program structure so that we can take it as a reference in upcoming chapters. Pascal Program Structure A Pascal program basically consists of the following parts − Every pascal program generally has a heading statement, a declaration…