1.Write a program to print Hello World.
SQL> begin
2 dbms_output.put_line('Hello World');
3 End;
4 /
PL/SQL procedure successfully completed.
SQL> set serveroutput on
SQL> /
Hello World
PL/SQL procedure successfully completed.
2.Write a program to find sum of two numbers from 1 to 100
WRITE A PROGRAM TO FIND SUM OF n natural numbers FROM 1 TO 100
DECLARE
N NUMBER(3):=1;
S NUMBER(4):=0;
BEGIN
WHILE N<=100
LOOP
S := S+N;
N :=N+1;
END LOOP;
DBMS_OUTPUT.PUT_LINE('THE SUM IS '||S);
END;
Output:-
The sum of Two Numbers is 15
3.Print Fibonnaci series using for loop.
declare
a number(3) := 0;
b number(3) :=1;
c number(3) :=0;
begin
dbms_output.put_line('Fibonacci series are upto 10 ');
for m in 1..10
loop
c:=a+b;
dbms_output.put_line(c);
a:=b;
b:=c;
end loop;
end;
Fibonacci series are upto 10
SQL> begin
2 dbms_output.put_line('Hello World');
3 End;
4 /
PL/SQL procedure successfully completed.
SQL> set serveroutput on
SQL> /
Hello World
PL/SQL procedure successfully completed.
2.Write a program to find sum of two numbers from 1 to 100
WRITE A PROGRAM TO FIND SUM OF n natural numbers FROM 1 TO 100
DECLARE
N NUMBER(3):=1;
S NUMBER(4):=0;
BEGIN
WHILE N<=100
LOOP
S := S+N;
N :=N+1;
END LOOP;
DBMS_OUTPUT.PUT_LINE('THE SUM IS '||S);
END;
Output:-
The sum of Two Numbers is 15
3.Print Fibonnaci series using for loop.
declare
a number(3) := 0;
b number(3) :=1;
c number(3) :=0;
begin
dbms_output.put_line('Fibonacci series are upto 10 ');
for m in 1..10
loop
c:=a+b;
dbms_output.put_line(c);
a:=b;
b:=c;
end loop;
end;
Fibonacci series are upto 10
0 comments:
Post a Comment
Thank you for your comments we will get back to soon