Sie sind auf Seite 1von 13

Page |1

Source Code --

--Find the Greatest Number Among 3 Numbers...

DECLARE
n1 number(6,2);
n2 number(6,2);
n3 number(6,2);

BEGIN
n1 := &n1;
n2 := &n2;
n3 := &n3;

if n1>n2 THEN
if n1>n3 THEN
dbms_output.put_line('Greatest Number is : '|| n1);
ELSE
dbms_output.put_line('Greatest Number is : '|| n3);
END IF;

ELSE
if n2>n3 THEN
dbms_output.put_line('Greatest Number is : '|| n2);
ELSE
dbms_output.put_line('Greatest Number is : '|| n3);
END if;
END IF;

END;
/

Output -

C:\Users\Mr. DARVIN KURRE\Documents\My Assignment PL-SQL.docx 10/7/2019 2:19:00 AM Mr. DARVIN KURRE
Page |2

Source Code --

DECLARE

n number(4);

BEGIN

n := 1;

dbms_output.put_line('List of Odd Numbers Upto 100 is : ');

while (n<100)

loop

IF mod(n,2)!=0 THEN

dbms_output.put_line(n);

END IF;

n:= n+1;

END loop;

END;

C:\Users\Mr. DARVIN KURRE\Documents\My Assignment PL-SQL.docx 10/7/2019 2:19:00 AM Mr. DARVIN KURRE
Page |3

Output -

C:\Users\Mr. DARVIN KURRE\Documents\My Assignment PL-SQL.docx 10/7/2019 2:19:00 AM Mr. DARVIN KURRE
Page |4

Source Code --

--Find the Even Number Between 400 to 500..

DECLARE

n number;
s number;

BEGIN
n := 400;
s := 1;
dbms_output.put_line('400-500 Odd Numbers Series is ...');

WHILE (n<=500)
loop
dbms_output.put_line(s ||' Even number is : ' ||n);
n:=n+2;
s:=s+1;
END loop;

END;
/

C:\Users\Mr. DARVIN KURRE\Documents\My Assignment PL-SQL.docx 10/7/2019 2:19:00 AM Mr. DARVIN KURRE
Page |5

Output -

C:\Users\Mr. DARVIN KURRE\Documents\My Assignment PL-SQL.docx 10/7/2019 2:19:00 AM Mr. DARVIN KURRE
Page |6

Source Code --

--Find Odd Numbers Between 1 to 100...

DECLARE
n number(6,2);

BEGIN
dbms_output.put_line('Reverse Number 1 to 10 ...');

FOR n in Reverse 1 .. 10
loop
dbms_output.put_line(n);
END loop;

END;
/

Output -

C:\Users\Mr. DARVIN KURRE\Documents\My Assignment PL-SQL.docx 10/7/2019 2:19:00 AM Mr. DARVIN KURRE
Page |7

Source Code --

--Find the Prime Number Between 1 to 100....

DECLARE
n number;
i number;
temp number;

BEGIN
n:=1;
dbms_output.put_line('Prime Numbers Bewtween 1 to 100 ...');

WHILE (n<100)
loop
temp:=0;
IF n=1 THEN
dbms_output.put_line(n);
END IF;

--Checking Number is Prime or Not..

FOR i in 1 .. n
loop
IF mod(n,i)=0 THEN
temp:=temp+1;
END IF;
END loop;
--Displaying Prime Numbers..
IF temp=2 THEN
dbms_output.put_line(n);
END IF;
n:=n+1;
END loop;
END;
/

C:\Users\Mr. DARVIN KURRE\Documents\My Assignment PL-SQL.docx 10/7/2019 2:19:00 AM Mr. DARVIN KURRE
Page |8

Output -

C:\Users\Mr. DARVIN KURRE\Documents\My Assignment PL-SQL.docx 10/7/2019 2:19:00 AM Mr. DARVIN KURRE
Page |9

Source Code --

--To check Year is Leap or Not...

DECLARE
n number(4);
BEGIN
n := &Year;
dbms_output.put_line('Entered Year is ' ||n);
IF mod(n,4)=0 THEN
dbms_output.put_line(n ||' is Leap Year');
ELSE
dbms_output.put_line(n ||' is Not Leap Year');
END IF;
END;
/

Output -

C:\Users\Mr. DARVIN KURRE\Documents\My Assignment PL-SQL.docx 10/7/2019 2:19:00 AM Mr. DARVIN KURRE
P a g e | 10

Source Code --

--Area of Triangle if all Side are equal...

DECLARE
Edge number(4);
area NUMBER (6,2);
BEGIN
Edge := &Edge;
area:=(sqrt(3)/4)*Edge*Edge;
dbms_output.put_line('Area of Triangle is : ' ||area || ' Square CM');
END;
/

Output -

C:\Users\Mr. DARVIN KURRE\Documents\My Assignment PL-SQL.docx 10/7/2019 2:19:00 AM Mr. DARVIN KURRE
P a g e | 11

Source Code --

-- Print the Fibonacci Series 1 to 100...

DECLARE
num1 number := 0;
num2 number := 1;
num3 number := 1;
BEGIN
dbms_output.put_line('Fibonacci Series is : ');
while (num3<100)
loop
dbms_output.put_line(num3);
num3 := num1+num2;
num1 := num2;
num2 := num3;
END loop;
END;
/
Output -

C:\Users\Mr. DARVIN KURRE\Documents\My Assignment PL-SQL.docx 10/7/2019 2:19:00 AM Mr. DARVIN KURRE
P a g e | 12

Source Code --

--Print the Series of 1, 2, 4, 8, 16, 32, 64, 128, 256, 512...

DECLARE
n number(4);
BEGIN
n := 1;
dbms_output.put_line('Series of 2s Power is : ');

while (n<=512)
loop
dbms_output.put_line(n);
n:= n*2;
END loop;
END;
/

Output -

C:\Users\Mr. DARVIN KURRE\Documents\My Assignment PL-SQL.docx 10/7/2019 2:19:00 AM Mr. DARVIN KURRE
P a g e | 13

Source Code --

DECLARE
n number;
Fact number;
BEGIN
n := &number;
Fact := 1;

dbms_output.put_line('Factorial of ' ||n || ' is ');

while (n>=1)
loop
Fact := Fact*n;
n := n-1;
END loop;
dbms_output.put_line(Fact);

END;
/

Output -

---000---

C:\Users\Mr. DARVIN KURRE\Documents\My Assignment PL-SQL.docx 10/7/2019 2:19:00 AM Mr. DARVIN KURRE