Here you will get plsql programs to print patterns of stars, numbers and alphabets.
Pattern 1:
* ** *** **** *****
declare n number:=5; i number; j number; begin for i in 1..n loop for j in 1..i loop dbms_output.put('*'); end loop; dbms_output.new_line; end loop; end; /
Pattern 2:
***** **** *** ** *
declare n number:=5; i number; j number; begin for i in reverse 1..n loop for j in 1..i loop dbms_output.put('*'); end loop; dbms_output.new_line; end loop; end; /
Pattern 3:
* ** *** **** *****
declare n number:=5; i number; j number; k number; begin for i in 1..n loop for j in 1..n-i loop dbms_output.put(' '); end loop; for k in 1..i loop dbms_output.put('*'); end loop; dbms_output.new_line; end loop; end; /
Pattern 4:
***** **** *** ** *
declare n number:=5; i number; j number; k number; begin for i in reverse 1..n loop for j in 1..n-i loop dbms_output.put(' '); end loop; for k in 1..i loop dbms_output.put('*'); end loop; dbms_output.new_line; end loop; end; /
Pattern 5:
* *** ***** ******* *********
declare n number:=10; i number:=1; j number; k number; begin while i<n loop j:=1; while j<n-i loop dbms_output.put(' '); j:=j+2; end loop; for k in 1..i loop dbms_output.put('*'); end loop; dbms_output.new_line; i:=i+2; end loop; end; /
Pattern 6:
********* ******* ***** *** *
declare i number:=9; j number; k number; begin while i>=1 loop j:=9; while j>i loop dbms_output.put(' '); j:=j-2; end loop; for k in 1..i loop dbms_output.put('*'); end loop; dbms_output.new_line; i:=i-2; end loop; end; /
Pattern 7:
* *** ***** ******* ********* ******* ***** *** *
declare n number:=10; i number:=1; j number; k number; begin while i<n loop j:=1; while j<n-i loop dbms_output.put(' '); j:=j+2; end loop; for k in 1..i loop dbms_output.put('*'); end loop; dbms_output.new_line; i:=i+2; end loop; i:=7; while i>=1 loop j:=9; while j>i loop dbms_output.put(' '); j:=j-2; end loop; for k in 1..i loop dbms_output.put('*'); end loop; dbms_output.new_line; i:=i-2; end loop; end; /
Comment below if you need any other pattern. I will try to add it here.
Hi, I need oracle query for the given pattern.
1
12
123
1234
declare
n number:=5;
i number;
j number;
begin
for i in 1..n
loop
for j in 1..i
loop
dbms_output.put(‘1’);
end loop;
dbms_output.new_line;
end loop;
end;
/
this is your required program
hello akash,
Dont give wrong program
declare
n number:=5;
i number;
j number;
begin
for i in 1..n
loop
for j in 1..i
loop
dbms_output.put(‘J’);
end loop;
dbms_output.new_line;
end loop;
end;
/
Declare
n number(1);=5:
i nimber(1):
j number (1):
Begin
For i in 1..n
loop
for j in j..i
loop
dbms_output.put(j):
end loop:
dbms_output.new_line:
end loop:
End:
/
declare
n number:=5;
i number;
j NUMBER := 1;
begin
FOR k IN 1..n LOOP
i:=i||j;
j:=j+1;
dbms_output.put_line(i);
END LOOP;
END;
declare
i number;
k number;
n number:=4;
begin
for i in 1..n
loop
k:=1;
while k<i+1
loop
dbms_output.put(k);
k:=k+1;
end loop;
dbms_output.new_line;
end loop;
end;
declare
n number:=5;
i number;
j number;
begin
for i in 1..n loop
for j in 1..i loop
dbms_output.put(j);
end loop;
dbms_output.new_line;
end loop;
end;
/
set serveroutput on
declare
n number:=5;
i number;
j number;
k PLS_integer:=1;
begin
for i in 1..n
loop
k:=1;
for j in 1..i
loop
dbms_output.put(k);
k := k+1;
end loop;
dbms_output.new_line;
end loop;
end;
/
DECLARE
I_NUM NUMBER:=1234;
PATTERN NUMBER;
BEGIN
FOR I IN 1..LENGTH(I_NUM) LOOP
PATTERN:=SUBSTR(I_NUM,1,I);
DBMS_OUTPUT.PUT_LINE(PATTERN);
END LOOP;
END;
OUTPUT LIKE:
1
12
123
1234
Declare
V_num number=1234;
Begin
For i in 1..4
Loop
Dbms_output.putline(substring(v_num,1,i);
End loop;
End;
BEGIN
FOR i IN 1..4
LOOP
FOR j IN 1..i
LOOP
dbms_output.put(j) ;
END LOOP;
dbms_output.new_line;
END LOOP;
END
Hi
how to print numbers in this format
1 2 3
4 5 6
7 8 9
declare
n number:=3;
i number ;
k number :=0;
j number ;
begin
for i in 1..n
loop
for j in 1..n
loop
dbms_output.put(j+k);
end loop;
dbms_output.new_line;
k:=k+3;
end loop;
end;
set serveroutput on
declare
n number:=3;
i number;
j number;
k pls_integer:=1;
begin
for i in 1..n
loop
for j in 1..n
loop
dbms_output.put(k);
k:=k+1;
end loop;
dbms_output.new_line;
end loop;
end;
/
Begin
for i in 1..9
loop
DBMS_OUTPUT.PUT(i);
IF MOD(i,3)=0 THEN
DBMS_OUTPUT.NEW_LINE;
CONTINUE;
END IF;
End loop;
END;
pl/sql is not able to add space
declare
n number:=10;
i number:=1;
j number;
k number;
begin
while i<n
loop
j:=1;
while j=1
loop
j:=9;
while j>i
loop
dbms_output.put(‘ ‘);
j:=j-2;
end loop;
for k in 1..i
loop
dbms_output.put(‘*’);
end loop;
dbms_output.new_line;
i:=i-2;
end loop;
end;
/
dbms_output.put(‘ ‘);
this line is not working
IF AM GIVING INPUT AS 1 THEN I NEED TO GET OUTPUT AS 1,IF INPUT IS 2 THEN OUTPUT SHOULD BE AS 2
2 2
IF INPUT IS 3 THEN OUTPUT SHOULD BE 3
3 3
3 3 3
*
# *
* # *
# * # *
* # * # *
please help this progarm
DECLARE
n NUMBER:=5;
i NUMBER;
j NUMBER;
BEGIN
FOR i IN 1..n LOOP
FOR j IN 1..i LOOP
DBMS_OUTPUT.PUT(i);
END LOOP;
DBMS_OUTPUT. NEW_LINE;
END LOOP;
END;
/
i want pascal triangle
how to print number in this format
1
2 3
4 5 6
set serveroutput on
declare
n number:=3;
i number;
j number;
k pls_integer:=1;
begin
for i in 1..n
loop
for j in 1..i
loop
dbms_output.put(k);
k:=k+1;
end loop;
dbms_output.new_line;
end loop;
end;
/
how to print
*
* *
* * *
* * * *
* * * * *
DECLARE
I NUMBER;
J NUMBER;
BEGIN
FOR I IN 1..5
LOOP
FOR J IN 1..I
LOOP
DBMS_OUTPUT.PUT(‘* ‘);
END LOOP;
DBMS_OUTPUT.NEW_LINE;
END LOOP;
END;
Hello!
How to Write a PL/SQL program to print the following series using nested for loop.
0 0 0 0 0
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25
Solve Pattern program is
Declare
K number;
I number;
J number;
Begin
For i in 0..5 loop
K := i ;
For j in 0..5 loop
Dbms_output.put_line ( K ) ;
K:=K+i ;
End loop;
Dbms_output.new_line;
End loop;
End;
/* 1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25 */
DECLARE
V VARCHAR2(20);
K VARCHAR2(10);
L VARCHAR2(10):=0;
BEGIN
FOR I IN 1..5 LOOP
K:=I;
FOR J IN 1..5 LOOP
L:=K*J;
V:=V||’ ‘||L;
END LOOP;
DBMS_OUTPUT.PUT_LINE(V);
V:=NULL;
END LOOP;
END;
/
BEGIN
FOR i IN 1..3
loop
FOR j IN 1..5
loop
DBMS_OUTPUT.PUT(i*j);
END LOOP;
DBMS_OUTPUT.NEW_LINE;
END LOOP;
END;
*
**
***
**
*
Pls provide me program for this pattern
Thank you
Hi, great work!! thanks for all this info here. Could you also tell us how to print just the diagonals of a square?
Hi
i need this flody’s triangle
1
2 3
4 5 6
7 8 9 10
Hii
I also need this flody’s trangle
1
2 3
4 5 6
7 8 9 10
declare
i number:=1;
j number:=0;
m number:=1;
begin
while(j<4)
loop
for k in i..(i+j)
loop
dbms_output.put(k);
end loop;
dbms_output.new_line;
j:=j+1;
i:=i+m;
m:=m+1;
end loop;
END;
/
Hlo, can you write code for the below pattern
15,14,13,12,11
10, 9, 8, 7
6, 5, 4
3, 2
1
1,2,3,6,10,15,21
in pl sql
4,7, 9, 11,12
if you perform any language
I need Pascal’s Triangle with brief introduction
1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
I WANT PLSQL CODE TO PRINT NAME IN DECREMENTAL ORDER:
Q
QU
QUE
QUER
QUERY
declare
var_name varchar2(10):=’QUERY’;
begin
for i in 1.. length(var_name)
loop
dbms_output.put_line(substr(var_name,1,i));
end loop;
end;
1
2 3
3 4 5
4 5 6 7
5 6 7 8 9
. . . . . . 90 91
i need this type of pattern program please send me
1
1 2 1
1 2 3 2 1
1 2 1
1
Given string loop and height 10, the magical pattern is
l
loo
loopl
looploo
looploopl
looplooploo
looplooploopl
looplooplooploo
looplooplooploopl
looplooplooplooploo
How to print following pattern in plsql
1
21
212
1212
12121
How to print this
DECLARE
n NUMBER:=&n;
i NUMBER;
j NUMBER;
k NUMBER:=1;
BEGIN
FOR i IN 0..n-1
LOOP
FOR j IN 0..i
LOOP
if MOD(k,2) 0 THEN
dbms_output.put(MOD(k,2));
else
dbms_output.put(2);
end if;
k:=k+1;
END LOOP;
dbms_output.new_line();
END LOOP;
END;
/
Can anybody please help with the pl sql query for fetching and printing data in a row in below pattern?
1~ABC~20-Jun-1998^2~CDE~09-Aug-1987^……
The above data already stored in a table, need here only is to print the fetched data in above pattern