Last Updated:

WriteLn Procedure in Pascal

Modern computer programs are able to modify certain data coming from various sources. The program first processes the information, interacts with them, and then gives it a modified shape. Alternatively, it can display other information data.

WriteLN Procedure

Accordingly, every programming language must have special tools. They are intended to the same extent for data input as well as for data output. In Pascal, input can be made through special procedures. They are called read() and readln(), while the manipulation of output can be carried out by means of write() and writeln().

Note! ln is a special ending that has specific purposes. Its purpose is to translate the pointer to a new line as soon as it is executed.

Ways to enter data into the program


That's another fundamental question. How can this be done? In most cases, data entry is done from files or via the keyboard. This raises another question concerning the area where such information data could be entered. There are several ways, among which you can note the input to the file, to the screen, or a printing device, such as a printer and so on.


The standard option is the keyboard. For output, this role is performed by the monitor screen. The standard ones point to those that are installed by default in most cases. Thus, if no other options are specified, the program will be able to read the data from the keyboard, and then transfer them to a computer monitor.

There is even a special name - a console, which combines the functional properties in this case of a monitor and a keyboard.

It turns out that the console acts as a standard device for input and output of information data.

Formatted output: how to work with it?


In the Pascal programming language, the output of system data to a file or screen is carried out through special procedures. They are called write() and writeln(). But we will consider only the first option here, concerning the output on the screen. Let's imagine that we need a few arbitrary phrases to appear on the screen. Let's say you decide that the phrase you typed in will start with a new line. In this case, writeln() will help us. If, on the contrary, you want the lines to follow each other in a continuous line, then write() will be required.

Write() in most cases is usually used if you want to display a particular user message on the screen. Following this process, it is possible to display data without transferring the existing cursor to a new line.

Let's say we want the screen to say "Enter a number: " After that, we wait for input, that is, we move our cursor to a new line.

There are many other examples. For example, it is enough to remember that some data is always stored in computer memory. You can refer to them in one way or another. Suppose you can follow them from a program by using variables such as num, fl, and st. There are various techniques for displaying them on the monitor screen and indicating their value.

procedure Writeln  Pascal-2

If you look at the above photo, you can see that the output procedure makes it possible to create input information as variables and constants, that is, from various kinds of components. In the third case, we resorted to the method of formatted output.

In this case, it is necessary to specify the number of available patterns, namely the width of the output field. This is a mandatory requirement for the displayed designation.

If we decide to derive the so-called fractional number, which is also called a real number, then the second number will be the number of characters following it immediately. It is necessary to indicate such information through a colon. If you do not format the real numbers, they will be displayed on the monitor screen in the same way as it was originally predetermined for your computer.

You can only indicate the number of signs, without paying attention to the fractional region. In this case, if there is no fixation of the fractional part, the output is made in the so-called exponential form.