Experiment-12
Object:
Write a program in PL/SQL to print
the following pattern
*
**
***
****
*****
Requirements: Windows XP, Oracle 9i.
Program Code:
SQL> declare
2 i
number(5);
3 j
number(5);
4
begin
5 for
i in 1..5
6
loop
7 for
j in 1..i
8
loop
9
dbms_output.put('*');
10 end
loop;
11
dbms_output.new_line;
12 end
loop;
13 end;
14 .
Output:
SQL> /
*
**
***
****
*****
PL/SQL procedure
successfully completed.
Result:Thus the above program in PL/SQL to
print a pattern has been successfully executed.
pattern for this
ReplyDeletea
b b
c c c
d d d d
e e e e e
*****
Delete****
***
**
*
BEGIN
DeleteFOR X IN 97.. &LAST LOOP
DBMS_OUTPUT.PUT_LINE(' ');
FOR Y IN 97..X LOOP
DBMS_OUTPUT.PUT(CHR(X));
-- DBMS_OUTPUT.PUT(CHR(Y));
-- DBMS_OUTPUT.PUT('*');
END LOOP;
END LOOP;
END;
/
****
Delete***
**
*
BEGIN
FOR X IN REVERSE 1.. &LAST LOOP
DBMS_OUTPUT.PUT_LINE(' ');
FOR Y IN 1..X-1 LOOP
-- DBMS_OUTPUT.PUT(CHR(X));
-- DBMS_OUTPUT.PUT(CHR(Y));
DBMS_OUTPUT.PUT('*');
END LOOP;
END LOOP;
END;
/
how to get
ReplyDelete2
4 6
8 10 12
14 16 18 20
22 24 26 28 30
DECLARE
DeleteN NUMBER :=0;
BEGIN
FOR O IN 0..5
LOOP
FOR I IN 0..O
LOOP
N:=N+2;
DBMS_OUTPUT.PUT(N||' ');
END LOOP;
DBMS_OUTPUT.PUT_LINE('');
END LOOP;
END;
/
1
ReplyDelete22
333
4444
55555
i need to programme was 1
ReplyDelete23
345
4567