PL/SQL Programs
1) Factorial:
DECLARE
num NUMBER := 5; -- Replace 5 with your desired number
factorial NUMBER := 1;
BEGIN
FOR i IN 1..num LOOP
factorial := factorial * i;
END LOOP;
DBMS_OUTPUT.PUT_LINE('Factorial of ' || num || ' is ' || factorial);
END;
2) Addition:
DECLARE
num1 NUMBER := 10; -- Replace with the first number
num2 NUMBER := 20; -- Replace with the second number
sum NUMBER;
BEGIN
sum := num1 + num2;
DBMS_OUTPUT.PUT_LINE('Sum is: ' || sum);
END;
3) Multiplication:
DECLARE
num1 NUMBER := 10; -- Replace with the first number
num2 NUMBER := 20; -- Replace with the second number
product NUMBER;
BEGIN
product := num1 * num2;
DBMS_OUTPUT.PUT_LINE('Product is: ' || product);
END;
4) Subtraction:
DECLARE
num1 NUMBER := 20; -- Replace with the first number
num2 NUMBER := 10; -- Replace with the second number
difference NUMBER;
BEGIN
difference := num1 - num2;
DBMS_OUTPUT.PUT_LINE('Difference is: ' || difference);
END;/