program SwapFirstAndLastDigit; var number, firstDigit, lastDigit, swappedNumber: integer; begin write('Enter a number: '); readln(number);
lastDigit := number mod 10;
while number >= 10 do begin number := number div 10; end; firstDigit := number;
swappedNumber := firstDigit * (power(10, trunc(ln(lastDigit))) + lastDigit div 10) + lastDigit mod 10;
if firstDigit <> lastDigit then begin writeln('Swapped number: ', swappedNumber); end else begin writeln('First and last digits are equal. No need to swap.'); end; end.
program SwapFirstAndLastDigit;
var
number, firstDigit, lastDigit, swappedNumber: integer;
begin
write('Enter a number: ');
readln(number);
lastDigit := number mod 10;
while number >= 10 do
begin
number := number div 10;
end;
firstDigit := number;
swappedNumber := firstDigit * (power(10, trunc(ln(lastDigit))) + lastDigit div 10) + lastDigit mod 10;
if firstDigit <> lastDigit then
begin
writeln('Swapped number: ', swappedNumber);
end
else
begin
writeln('First and last digits are equal. No need to swap.');
end;
end.