Pl/SQL Program for Palindrome Number

A palindrome number is a number that remains the same when its digits are reversed. example:- 16461


Pl/SQL Program for Palindrome Number

declare
    num1 number;
    num2 number;
    rev number:=0;
    rem number;
 
begin
    num1:=13531;
    num2:=num1;
  
    while num1>0
    loop
        rem:=mod(num1,10);
        rev:=(rev*10)+rem;
        num1:=trunc(num1/10);
    end loop;
    
    if num2=rev
    then
        dbms_output.put_line('number is palindrome');
    else
        dbms_output.put_line('number is not palindrome');
    end if;
end;

Output:-

number is palindrome
https://bit.ly/2lgLuJ1 https://bit.ly/2lAbgYW https://bit.ly/2ngU8ry

Leave a Reply

Your email address will not be published. Required fields are marked *