Make a program for the exchange of values of two variables: according to the following scheme
September 10, 2021 | education
| Make a program for the exchange of values of two variables: according to the following scheme: b-assign a value with a-assign a value b.
Let’s compose a program for exchanging the values of two variables:
Program 1;
Var a, b, c: integer;
begin
writeln (‘enter the value of the variable a’);
readln (a);
writeln (‘enter the value of variable b’);
readln (b);
c: = a;
a: = b;
b: = c;
writeln (‘Received value a =’, a);
writeln (‘Received value b =’, b);
end.
Let’s check the work of the program by going through the code sequentially:
Enter unknown variables a and b from the keyboard:
a = 5;
b = 7;
Let’s move on to the exchange:
c = 5;
a = 7;
b = 5;
The screen displays the following:
a = 7;
b = 5.
Thus, the exchange of variables took place.
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.