Algorithmic language is a formal language used to write, implement, or study algorithms. Main service words of an algorithmic language

Any programming language is replete with a variety of keywords, functions or classes. As a rule, they all use English, which describes methods or arguments. In some environments, there are simply reductions in machine functions. This greatly hampered the development of the development in the initial stages. In order to increase the speed of understanding, a series of special algorithmic programming languages ​​was created, which consisted of clear and accessible words and their combinations, clear even to an untrained person.

A bit of history

To communicate with the first computers, programming languages ​​were used as close as possible to the machine code consisting of zeros and ones. Naturally, remembering a lot of commands was a very difficult task. In addition, the method of allocating memory during programming was completely laid on the shoulders of the developer. And if he made a small mistake, then he had to redo everything first.

algorithmic language

A large role in the transition from machine language to a more appropriate person has been played by a low-level programming language assembler. It used mnemonic meanings and symbols. This simplified the task of the developer, since now he could more efficiently build his algorithms from combinations of control instructions and numerical codes. Despite all its flexibility and power, the language was still difficult to master.

For training in development and algorithms in educational institutions, the introduction of the basic programming language has begun. He already contained a lot of commands, keywords, understandable to the student. BASIC is still used to master the basics of programming.

With the creation of the first algorithmic programming language - Algol - the development of algorithms has accelerated significantly.

What is the algorithm

If you get away from the dry theory and definitions, the algorithm is a sequence of actions aimed at solving the problem. Despite all the ornateness of expression, a person faces this concept every day. For example, to drink tea, you need to perform the following sequence:

  1. Put the kettle on the stove.
  2. Wait for it to boil.
  3. Pour boiling water into the water.
  4. Drop the tea bag into the cup.
  5. Add the required amount of sugar, milk or honey.

This sequence is very simplified, but it is the simplest algorithm.

algorithmic programming language

Just like a person, a computer is capable of performing a specific sequence of tasks. However, in order for it to clearly understand them, it must be borne in mind that for computers there are no many obvious concepts for people. In addition, the algorithm must accurately describe all the necessary actions. For this purpose, and serves as an algorithmic language that creates a bridge between the machine and man.

Properties and features of an algorithmic language

Algorithmic - a formal language that describes the algorithms that are supposed to run on computers. As a rule, it is not tied to any machine architecture. This helps to significantly increase and speed up the writing of code. As a vivid example - the algorithmic language BASIC. Pascal and C also proved popular because they had a simple syntax and speed of learning.

The structure is implemented in such a way that the procedures described in the code are executed one after another. That is one algorithm - one task. This is similar to creating functions or methods in C and Java languages.

All code is built from keywords that describe an event or variable.

Differences between machine and algorithmic languages

A prominent representative of the machine-dependent language is the assembler. Programming on it boils down to specifying the translator with special marks, what and where to move or what data area to fill. Since the assembler syntax is more like a machine, it is quite difficult to study and write code on it. Below you can see how commands for different processors may look.

formal language

Therefore, a formal language or algorithmic was created with a large number of human-readable keywords and names.

Keywords

Algorithmic language consists of keywords, which are abbreviations for the complete designation of actions or variables. This allows you to reduce the length of the code, while keeping it clear.

  • Alg. Any algorithm starts with this keyword. It describes the name and in parentheses indicates which arguments it takes to calculate, and what should be the result.
  • Arg. Indicates the arguments of the algorithm. Reflects the type and name of the value that will be used in the code.
  • Res. This keyword is used to indicate the type and name of the variable in which it will be necessary to place the result of the calculation.
  • EarlyIndicates the immediate beginning of the execution of the algorithm. Lasts to the keyword con. The whole interval from "beginning" to "con" is called the body of the current algorithm.
  • KonReports that the execution of the algorithm is over.
  • Given. Speaks about some features and nuances of using the algorithm or about limitations. For example, here you can specify that the lengths of the compared strings should be the same.The use of the keyword "given" is optional.
  • Need to. A more detailed description of what should result from the execution of the algorithm. As well as "given", it can be omitted, but to build a more understandable and detailed code, its use is recommended.

The list of these keywords refers to the title and designation of the body of the algorithm. And here are the lexemes for variables:

  • Whole. The variable type of integers. Their range should vary from -32768 to 32767.
  • Things. Real numbers. For example, with an exponential or fractional part.
  • Log. This keyword means that a variable of logical type will be used that can only accept "yes" or "no."
  • Sim.This includes values ​​with single characters, for example, "a", "3".
  • Lit. String variables that can contain whole text strings.
  • Tab. Indicates a table with data of a certain type. It is an analogue of an array from other programming languages.

service words

Additional service words

The following list of words is used to organize branching and looping mechanisms.

  • For. It is used to iterate through all values ​​of a specific range. Used for cycles, t.e. continuous performance of any data procedures.
  • From and to. Indicates exactly which range of values ​​to loop through in the "for" type loop.
  • Till. Also serves to iterate over several values. Used to work until a certain condition is met.
  • Nc and kc. "Нц" in algorithmic language means the beginning of the cycle body, and "kz" - the end. Between these two keywords are embedded necessary to calculate the procedure.
  • If.With this word, the branch structure is realized. In this way, it is possible to determine the course of the program in the right direction, taking into account the conditions.
  • That, otherwise. Two words, paired with "if." Also build a branching mechanism.
  • Selection. A handy tool for implementing branching from multiple values ​​of the same type. Works in conjunction with the keyword "when" and "otherwise."
  • All. Means the end of the branch mechanism.
  • Input. This keyword allows the user to enter values ​​of variables in the course of the program for further processing.
  • Conclusion.Produces data output to the screen.

Basic language structures

Algorithmic programming language helps to build various structures that produce computational functions in a convenient form.In general, any language can use several specific mechanisms and their combinations.

components of an algorithmic language

Following structure

When designing this type of structure, code execution takes place directly line by line. A general example can be expressed as follows:

alg The sum of two numbers (arg integer a, b, res integer S)

nach

input a, b

S: = a + b

output “S =”, S

con

In this example, the sum of two numbers entered by the user is calculated. At the beginning, the word "al" indicates that the algorithm begins, and briefly describes what it does. The brackets define the arguments required for the program, and the variable that will serve as a container for storing the results. Next comes the "beginning" keyword, showing the immediate beginning of the execution of expressions and procedures. Next to the "beginning" you can define some intermediate variables.

nts in algorithmic language

In the body of the algorithm, the key word "input" takes data from the user and writes them into variables. Then they are added up, and their sum is assigned to S. Before the end of the algorithm, the result of the program is displayed on the screen by means of the keyword "output". This recording in an algorithmic language is typical for many other programming environments.

Branch structure

The course of the program does not always have to be performed line by line.Sometimes you need to define or change the value of a variable depending on the situation. For example, provided that x = 0, do not divide by x.

The algorithmic programming language for this uses several variants of constructions and the keywords "if", "then", "otherwise" or "choice". After the "if" condition is established by which the criterion of transition to another branch will be determined. For example:

if x = 0

then y = 1

all

In this way, you can change the values ​​of variables depending on other factors. This example does not fully cover all possible implementations. Therefore, in addition to the design, the keyword "otherwise" is applied. It allows you to move to another branch if the condition does not match the selected criteria.

if x = 0

then y = 1

otherwise y = 0

all

That is, in the case when x is not equal to zero, y will also be reset, regardless of the value it had before.

A more convenient means for implementing multiple choice is the "choice" construction. It allows you to sort out several conditions. When one of them fires, the action specified for it will be performed.

the choice

when x = 0: y = 0

with x = 1: y = 1

with x = 2: y = 2

all

This example demonstrates the dependence of the variable y on x. The program runs through all the data and compares the current value of x with the specified in the condition. When a match is found, it performs the action following it. This design can also be combined with the "otherwise" keyword for more flexible solutions when none of the conditions have worked.

Cycles

Cycles play a very important role in programming. Virtually no development can do without the implementation of this design. In the general case, cycles solve the problem of performing actions of the same type with several variables repeatedly. This is convenient, for example, when filling arrays with data using a well-known formula, sorting it, or counting some values.

The key word "bye" allows you to organize a cycle in which a certain action will be repeated until a condition is satisfied. For example:

ns while x <= 3

y: = y + x

x: = x + 1

kc

In this example, y will increase until x is greater than 3. In order for the loop to be infinite, x needs to be changed in a large direction in each pass, for example, 1, which the second line of code does.

The keyword "for" is applied to a certain range of numbers, which must be iterated sequentially, performing any actions with them. This construction is used when a finite number of elements is known.

Its syntax is:

nts for x from 1 to 3

y: = y + x

kc

The official words "from" and "to" indicate the range of values ​​that must be searched. Thus, in the first iteration, x = 1, as a result of the passage, y will also acquire the value 1. Then the control again goes to the beginning, and x will now be equal to 2, respectively, y will become 3.

Using joint loop and branching constructions, you can build simple algorithms for solving easy problems and gaining knowledge about the work of programming languages.

Standard features

Algorithmic language has standard functions that are already built into it. They can facilitate some routine operations with numbers and expressions. The standard functions of an algorithmic language can calculate square root, logarithms, modules, sines, cosines, and so on:

  • absolute modulus is abs (x);
  • square root - sqrt (x);
  • natural and decimal logarithms - ln (x) and lg (x);
  • the minimum and maximum of two numbers - min (x, y), max (x, y);
  • sine, cosine, tangent, cotangent - sin (x), cos (x), tg (x), ctg (x).

These standard features allow you to avoid creating a "bicycle", helping to implement the simplest functions of regular means.

Boolean expressions

Logical expressions reflect whether an operation satisfies a condition. For example, x> 0 will be true when x equals 1, 2, 25, or any other number greater than zero. The algorithmic language contains logical expressions that, in addition to standard mathematical operations, can use the following keywords and operators:

  • AND.It means that the expressions between which the keyword is located must satisfy a certain condition: (x> 0) and (y> 0);
  • Or. One of the expressions may not satisfy the condition, for example, (x> 0) or (y> 0);
  • Not. "Flips" the logical value of an expression. For example, such a constructionnot(x> 0) means that x must still not be greater than zero.

Also, there are comparison operators - <,>, =, which can be combined to create type expressions greater or equal.

A small program for algorithmic language

Next is a small sample code.Educational algorithmic language allows you to create sample models of real large software systems that solve the most complex tasks.

To understand the process, you can organize a program that interacts with the user. She will request a number, and the car will square it.

The components of an algorithmic language are composed of many keywords. The first thing the program starts with is the announcement of the algorithm - al.

al Square the number ()

In brackets you need to specify an argument that will be a value from the user and the result. Also do not forget about the announcement of the types of data.

alg Squareing a number (arg cx, cz S)

Now the machine will know that it will have to interact with an integer-type variable, and the result of its work will be S.

Next comes the beginning of the algorithm body, in which you can define intermediate values ​​if necessary.

nach

The first thing to do is to perform data entry. This is done using the keyword "input".

input x

Now, directly in the body of the algorithm, it is necessary to describe a series of commands with the help of which the squares of numbers will be calculated.

S: = x * x

output “S =”, S

The algorithmic language, the commands of which allow one to realize the assignment, is written as: =. Thus, the variable S gets the value of the product x on itself. A line with the output shows the result on the screen. Well, all this ends with the keyword "con". The full code will now look like this:

alg Squareing a number (arg cx, cz S)

nach

input x

S: = x * x

output “S =”, S

con

This is the simple way to implement the algorithm for calculating the square of the entered number. The program can be complicated by adding to it the sum of all operations. And then it will look like this:

al Squareing a number and calculating their sum (arg cx, cz S)

given | x> 0

need to | S = 1 * 1 + 2 * 2 + ... + x * x

nach is whole

input x; S: = 0

nts for a from 1 to x

S: = S + a * a

kc

output “S =”, S

con

In this variant, a cycle, an intermediate variable a and a brief instruction to the task in the sections "given" and "necessary" are used. Now, if you transfer a certain number to the program, it will square it and output the sum of squares of all the numbers that precede it.

Use and development of algorithmic languages

Algorithmic language is common in the learning environment for understanding basic norms and rules of programming. For example, BASIC, which are held in many schools.It perfectly reflects all the paradigms of such a term as an imperative programming language in which all commands are executed sequentially one after another.

program for algorithmic language

Because of the approximation of the described constructions and keywords to the human language, writing code has become much easier than on fully machine or machine-dependent models. The family of programming languages ​​Algol has gone farthest in its development, since its syntax has been introduced in several localizations. It was possible to write the code even in Russian.

In general, the development of algorithmic languages ​​strongly influenced programming as a whole and allowed a large number of people to become developers. Modern tools are becoming more accessible and understandable. High level programming languages ​​contain more and more functions with speaking names and titles. The limits of their use is becoming less. Thus, in the future, a more understandable and natural implementation of the development is possible.

Related news

Algorithmic language is a formal language used to write, implement, or study algorithms. Main service words of an algorithmic language image, picture, imagery


Algorithmic language is a formal language used to write, implement, or study algorithms. Main service words of an algorithmic language 32


Algorithmic language is a formal language used to write, implement, or study algorithms. Main service words of an algorithmic language 86


Algorithmic language is a formal language used to write, implement, or study algorithms. Main service words of an algorithmic language 40


Algorithmic language is a formal language used to write, implement, or study algorithms. Main service words of an algorithmic language 34


Algorithmic language is a formal language used to write, implement, or study algorithms. Main service words of an algorithmic language 87


Algorithmic language is a formal language used to write, implement, or study algorithms. Main service words of an algorithmic language 21


Algorithmic language is a formal language used to write, implement, or study algorithms. Main service words of an algorithmic language 89


Algorithmic language is a formal language used to write, implement, or study algorithms. Main service words of an algorithmic language 69


Algorithmic language is a formal language used to write, implement, or study algorithms. Main service words of an algorithmic language 4