PL/SQL block to reverse a given number

Q. Write a PL/SQL block to reverse a given number.

Answer:

The following program can reverse the number entered by the user.

For example:
Number 123 is displayed as 321

declare
  num1 number(5);
  num2 number(5);
  rev number(5);
begin
  num1:=&num1;
  rev:=0;
  while num1>0
  loop
    num2:=num1 mod 10;
    rev:=num2+(rev*10);
    num1:=floor(num1/10);
  end loop;
  dbms_output.put_line('Reverse number is: '||rev);
end;
/


Output:

reverse number