Write a pascal program that swaps the last two digits of a number. Numbers in the range from m to n are
Write a pascal program that swaps the last two digits of a number. Numbers in the range from m to n are considered, and m is 99. Display two columns of values: the first is the original number, the second is the modified one.
program zz1;
var a, b, r, i, d, m, n: integer; // set variables of integer type
begin
write (‘enter the first number m> 99’); // enter the first number from the keyboard
read (m);
write (‘enter the second number’); // enter the second number from the keyboard
read (n);
for i: = m to n do // organize a loop in which we iterate over all numbers from m to n
begin
r: = i;
a: = r mod 10;
r: = r div 10;
b: = r mod 10;
r: = r div 10;
d: = (r * 10 + a) * 10 + b; // form a new number
writeln (‘original number’, i, ‘modified’, d); // display the answer
end;
end.