PL/SQL Program for Armstrong Number
PL/SQL Program for Armstrong Number Here you will learn pl/sql program for armstrong number using power function in pl/sql programming. 153 is an Armstrong number because: 13 + 53 + […]
PL/SQL Program for Armstrong Number Here you will learn pl/sql program for armstrong number using power function in pl/sql programming. 153 is an Armstrong number because: 13 + 53 + […]
PL/SQL Program for Palindrome Number Here you will learn pl/sql program for palindrome number using substr function in pl/sql programming. PL/SQL Program for Palindrome Number
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | DECLARE input_number NUMBER := &Enter_Number; -- User will input the number rev_number NUMBER := 0; -- variable to store reverse number temp NUMBER; -- variable to store temp number rem NUMBER; -- variable to store remainder number BEGIN temp := input_number; -- reverse the digits of number WHILE temp > 0 LOOP remainder := MOD(temp, 10); -- Get the last digit rev_number := (rev_number * 10) + rem; -- Build the reversed number temp_number := FLOOR(temp_number / 10); -- Remove the last digit from the number END LOOP; -- Print input and reversed numbers DBMS_OUTPUT.PUT_LINE('Input Number: ' || input_number); DBMS_OUTPUT.PUT_LINE('Reversed Number: ' || rev_number); -- Check if input number is equal to the reversed number IF input_number = rev_number THEN DBMS_OUTPUT.PUT_LINE('The number is a palindrome.'); ELSE DBMS_OUTPUT.PUT_LINE('The number is not a palindrome.'); END IF; END; / |
Output Enter_Number 1259
PL/SQL Program for Palindrome String Here you will learn pl/sql program for palindrome string using substr function in pl/sql programming. PL/SQL Program for Palindrome String
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | DECLARE old_str VARCHAR2(50); new_str VARCHAR2(50); BEGIN -- Prompt to get user input DBMS_OUTPUT.PUT_LINE('Enter a string:'); -- store user input old_str := '&input_string'; -- Loop to reverse the old string FOR i IN REVERSE 1..LENGTH(old_str) LOOP new_str := new_str || SUBSTR(old_str, i, 1); END LOOP; -- Print Old and New Reversed strings DBMS_OUTPUT.PUT_LINE('Old String: ' || old_str); DBMS_OUTPUT.PUT_LINE('New String: ' || new_str); -- Check if the old string is equal to new string IF old_str = new_str THEN DBMS_OUTPUT.PUT_LINE('The string is a palindrome.'); ELSE DBMS_OUTPUT.PUT_LINE('The string is not a palindrome.'); END IF; END; / |
Output 1 Enter
PL/SQL Program to Reverse a String Here you will learn pl/sql program to reverse a string using substr function in pl/sql programming. PL/SQL Program to Reverse a String
1 2 3 4 5 6 7 8 9 10 11 12 | DECLARE old_str VARCHAR2(50) := 'Hello, PL/SQL'; new_str VARCHAR2(50); BEGIN FOR i IN REVERSE 1..LENGTH(old_str) LOOP new_str := new_str || SUBSTR(old_str, i, 1); END LOOP; DBMS_OUTPUT.PUT_LINE('Old String: ' || old_str); DBMS_OUTPUT.PUT_LINE('New String: ' || new_str); END; / |
PL/SQL Program to print odd numbers using for loop Numbers that cannot be evenly divided by 2 are known as odd numbers. In this program, we will generate a list
PL/SQL Program to print odd numbers using for loop Read More »
PL/SQL Program for Fibonacci Series Here you will learn pl/sql program for fibonacci series. It is a series, in which each number is the sum of the last two previous
PL/SQL Program for Reversing a Number Here you will learn pl/sql program for reversing a number. Reversing number means reverse the digits of a number. For example: Input Number =
PL/SQL Program to Print Table of a Number In this program you will learn to create pl/sql program to print table of a number using for loop. PL/SQL Program
PL/SQL Program to Find Factorial of a Number Let’s do the PL/SQL Program to Find Factorial of a Number. Factorial are those number which can divide by one or itself
PL/SQL Program for even or odd number Here you will get PL/SQL program for even or odd number checker. If a number is completely divisible by 2 is called even