In this program, you will learn to check whether the number entered by the user is palindrome or not.
when the reversed number is equal to the original number then the number is a palindrome. for example, 101, 121, 1234321, etc are palindrome numbers.
declare
n number;
copy number;
rev number := 0;
begin
/* take input from user */
n:=&n;
copy:=n;
while(copy>0)
loop
/*It will find the reverse of the number entered by the user.*/
rev := rev * 10 + mod(n,10);
copy := copy / 10;
end loop;
/* check if reverse number is equal to original number */
if (n = rev)
then
dbms_output.put_line(n||' is palindrome number');
else
dbms_output.put_line(n||' is not palindrome number');
end if;
end;
/
Enter value for n: 123 old 7: n:=&n; new 7: n:=123; 123 is not palindrome number
n
.rev
.n
and rev
(reverse number). if both are the same then the number is a palindrome
.