Sunday, May 28, 2017

Palindrome Program in Oracle PL/SQL

A very simple program that I wrote using Oracle PL/SQL to accept input string from the user and then it will check if the given string is a Palindrome or Not a Palindrome. I am still a beginner in Oracle PL/SQL programming I hope you will find my work useful. Thank you.


My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.




Input of Values Screen Shots






Sample Program Output



Program Listing

/* Palindrome Program in Oracle PL/SQL                    */
/* Written By Mr. Jake R. Pomperada                          */
/* Language : PL/SQL                                                  */
/* Date     : May 28, 2017  Sunday                             */

SET SERVEROUTPUT ON;
DECLARE
        
         get_string varchar2(50);
         rev_string varchar2(50);
         a          number(5);
         
         title   varchar2(50) :='Palindrome Program in PL/SQL';
         author   varchar2(50) :='Written By: Mr. Jake R. Pomperada,MAED-IT';
         
    BEGIN
          
             get_string := '&get_string';
             
             for a in reverse 1..length(get_string) loop
               rev_string := rev_string || substr(get_string,a,1);
             end loop;
             
             dbms_output.put_line(chr(13)||chr(10) || UPPER(title));
             dbms_output.put_line(chr(13)||chr(10) || UPPER(author));
              dbms_output.put_line(chr(13)||chr(10)); 
             dbms_output.put_line('The original string is ' || UPPER(get_string) || '.');
             dbms_output.put_line(chr(13)||chr(10)); 
             dbms_output.put_line('The reverse string is ' || UPPER(rev_string) || '.');
   
   
      IF rev_string = get_string
   THEN
                 dbms_output.put_line(chr(13)||chr(10) || 'The given string ' || UPPER(get_string) || ' is a Palindome.');
                 dbms_output.put_line(chr(13)||chr(10)); 
                 dbms_output.put_line('END OF PROGRAM');
   ELSE 
                 dbms_output.put_line(chr(13)||chr(10) || 'The given string ' || UPPER(get_string) || ' is Not a Palindome.');
                 dbms_output.put_line(chr(13)||chr(10)); 
                 dbms_output.put_line('END OF PROGRAM');
    END IF;
          
   END;
   



No comments:

Post a Comment