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.
The post PL/SQL Program to Print Patterns appeared first on The Crazy Programmer.
from The Crazy Programmer https://www.thecrazyprogrammer.com/2017/10/plsql-program-print-patterns.html
Comments
Post a Comment