The following algorithm uses integer variables x and y. Determine the value of the variable x after

The following algorithm uses integer variables x and y. Determine the value of the variable x after executing the following algorithm: x: = 0 y: = x * x – 5 x: = div (y, 5) + 4

Opposite each program command, write the value of the corresponding variables:

x: = 0 → x = 0;

y: = x * x – 5 → y = 0 * 0 – 5 = -5;

x: = div (y, 5) + 4 → x = div (-5, 5) + 4 = -1 + 4 = 3.
(div – integer division).

Answer: 3.

Working program in Pascal language:

program calc;
var x, y: integer;
begin
x: = 0;
y: = x * x – 5;
x: = y div (5) + 4;
writeln (‘x =’, x)
end.



One of the components of a person's success in our time is receiving modern high-quality education, mastering the knowledge, skills and abilities necessary for life in society. A person today needs to study almost all his life, mastering everything new and new, acquiring the necessary professional qualities.