Friday, 13 November 2015

pl sql program for 'palindrome'

Write a program in PL/SQL to check whether a number is a palindrome or not.

In this article, we will see the program for Palindrome in Pl/Sql.

palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward. Allowances may be made for adjustments to capital letters, punctuation, and word dividers.

Let's see the program for this.

sql> set serveroutput on
2  g varchar2(20);
3  r varchar2(20);
4  i number(4);
5  begin
6  g:='&g';
7  for i in reverse 1.. length(g) loop
8  r:=r || substr(g,i,1);      
9  end loop;
10  dbms_output.put_line('reverse string is ' || r);
11  if r=g then
12  dbms_output.put_line('String is Palindrome');
13  else
14  dbms_output.put_line('String is not Palindrome');
15  end if;      
16  end;
17  /


No comments:

Post a Comment