

Pascal is a high-level programming language that was developed by Swiss computer scientist Niklaus Wirth in 1971. It is named after the mathematician Blaise Pascal, who, in 1642, designed the first mechanical calculator to be produced and distributed.
Wirth developed Pascal to help teach the concepts of structured programming. He wanted to teach the "correct" way to write computer programs using various programming languages. Thus, Pascal was designed to teach good programming techniques. Because of this, Pascal became one of the most preferred languages to teach to beginners in computer programming. There were also many versions of Pascal for use in personal computers.
Format of a Pascal program:
BEGIN
Statements;
END.
The PROGRAM statement states the name of the program. Then, the actual instructions
and main portions of the program are written between the BEGIN and END statements.
There can be more than one statement contained within this body section. However,
each separate statement must end with a semicolon.
Data Types:
There are four types of data in the Pascal programming language:
Basically, the Boolean data types in the Pascal programming language are either TRUE or FALSE.
In an AND operation:
The statement is true if both of the expressions are true
In an OR operation:
The statement is true if one expression, or both expressions are true
In a NOT operation:
The opposite occurs: If the input is true, than the statement is false, and v ice versa
2. Char:
3. Integer:
For example:
4. Real:
For example:
Operators:
In order for your computer to be able to perform mathematical computations, it needs to have certain instructions. In turn, there needs to be certain symbols to represent the basic mathematical operators, like addition, subtraction, etc. Here's a list of a few of the basic operators:
| + | Addition |
| - | Subtraction |
| * | Multiplication |
| / | Division |
| DIV | Division with only integers |
| MOD | The remainder from integer division |
As you know from math class, there needs to be an order of operations for mathematical computations. There must be some sort of rule as to which operations you perform first. Here's the order of operations for computations in the Pascal language:
2. Negation (negatives)
3. Multiplication and Division
4. Addition and Subtraction
Also, in every mathematical equation, there are always relational operators.
These are used for comparing two expressions (for example, the equal sign,
greater than or less than signs, etc.) Some Pascal relational operators:
| < | Less than |
| > | Greater than |
| = | Equal to |
| <> | Not equal to |
| < = | Less than or equal to |
| > = | Greater than or equal to |
Control Statements:
Pascal programs are controlled by certain control statements. They control which actions should be performed, how many times they should be performed, etc. Some basic control statements are:
IF Boolean Expression
THEN Statement
ELSE Second Statement
First, you plug in a value for a Boolean expression- either TRUE or FALSE. Then, the expression itself is carried out. Let's say you put in a FALSE, and the Boolean expression was NOT. A TRUE would come out. The then statement will then be executed. However, let's say you put in a TRUE. Then, a FALSE would come out. This time, instead of executing the then statement, the else statement would be executed.
WHILE
DO
:
The WHILE DO statement is kind of similar to the IF THEN ELSE statement. The basic format is:
WHILE Boolean Expression
DO Statement
The Boolean Expression, whether it be AND, OR, or NOT, is first carried out. If the result is TRUE, the DO statement will then be performed. However, if the result is FALSE, the DO statement will not be executed.
REPEAT
UNTIL
:
The format of this is:
REPEAT Statement
UNTIL Boolean Expression
Basically, whatever the statement says is executed. Then, it is plugged into the Boolean expression. If the expression comes out to be FALSE, then the statement is executed again. If the expression is TRUE, then the statement is not repeated.
1995-2001, ThinkQuest Inc.all rights reserved



