Pascal Programming Language is one of the oldest languages like BASIC, ALGOL, FORTRAN, COBOL, and AL used in writing instructions for a computer.
It is also one of the easiest languages a beginner can program in because it is easy to learn, understand, and its less complicated to codes written in C++, Java, and the rest; but then there are limitations to what you can do with it compared to the latter languages.
With the Pascal Programming Language, the simplest mathematical operations such as Addition, Subtraction, Division of real numbers, and Average of a range of numbers can be carried out.
Also, mathematical operators can be used in any Pascal code example as is the case in this post.
That being so, let's look at the logic of the program.
Logic of The Program
In the Pascal codes below, a section or subprogram performs a specific operation using two numbers.
The operation carried out is determined by the Number (Selection Key) entered by the user.
Our Selection Keys are 1, 2, 3, 4, 5, and 6, where on key presses, an operation must occur be it an arithmetic operation or exit from the Program.
We have used the IF-THEN Statement here, ensuring that one subprogram or the another must be executed depending on the user's select key choice.
The program is terminated if the selection key is 6, whereas the other keys will actually compute two random numbers entered by the user.
Now if you get the logic behind this simple program, you can write more complex ones most especially if you're good with numbers.
Also Read: BASIC Program For Sum of Numbers Using IF Then Statement
Pascal Program to Create and Save Records in a Textfile
Pascal Program of Matrix Multiplication
Following the logic in the above Pascal Calculations, If you have more numbers you can use a looping statement which will save time instead of the If -Then statement.
If you have questions regarding the code above, please drop a comment and we'll respond immediately.