## PASCAL

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:

PROGRAM name (INPUT,OUTPUT);

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:

1. Boolean:

Boolean data is data that uses Boolean Algebra. Boolean Algebra is a type of logic system whose basic ideas are "AND," "OR," and "NOT."

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:

Char represents the word "character." The data types stored here are single characters-for example, a letter in the alphabet.

3. Integer:

These data types can be any integer. For those of you who don't know, and integer is any number that does not have a fractional component.

For example:

1, 234, 6832, -32, and -43657 ARE all integers.
1.5, 2/5, 45/865, -.3256, and -5/9 are NOT integers

4. Real:

These are data types in the Pascal language that contain any real number. Real numbers are any number that is not imaginary. And if you don't know, an imaginary number is denoted by the letter i. There is no real technical definition for an imaginary number. Basically, an imaginary number is the square root of -1. Of course, we all know that we can't have a negative number under the radical sign. Well, mathematicians have decided to make up an imaginary number that's the square root of -1. There's no real definition for this. It's just one of those things that just is. No questions asked.

For example:

1, 2.56, 56/100, -34, ?2, and ?45 are all REAL numbers

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:

1. Parentheses

2. Negation (negatives)

3. Multiplication and Division

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… THEN… ELSE… :

There are many versions of this type of statement. One example:

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.

Continue on to the next programming language:
C