Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

PLSQL_Programs

Plsql program

Uploaded by

khaparderahil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

PLSQL_Programs

Plsql program

Uploaded by

khaparderahil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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;/

You might also like