PL/SQL Program to Check Number is Palindrome or Not

PL/SQL Program to Check Number is Palindrome or Not:



declare
no number(15);
rev number(15);
slen number(10);
c char(1);
Begin
no:=:no;
slen:=length(no);
for i in reverse 1..slen
loop
c:=substr(no,i,1);
rev:=rev||c;
end loop;
dbms_output.put_line('Orignal Number: '||no);
dbms_output.put_line('Reversed Number: '||rev);
if(no = rev) then
dbms_output.put_line('Given Number is Palindrome');
else
dbms_output.put_line('Given Number is not Palindrome');
end if;
end;

OUTPUT:

Original Number: 1211
Reversed Number: 1121
Given Number is not Palindrome
-------------------------------------------------
Original Number: 121
Reversed Number: 121
Given Number is Palindrome

Leave a Reply

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

1 × 1 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.