Tutorialspoint.dev

Print Patterns in PL/SQL


You have given a number n then you have to print number a right-angled pyramid of *

Examples:

Input : 3
Output :
*
**
***

Input : 7
Output :
*
**
***
****
*****
******
*******
declare
  
    -- declare variable n,
    i and j-- of datatype number
        n number :
    = 7;
i number;
j number;
  
begin
      
    -- loop from 1 to n
    for i in 1..n
    loop
        for j in 1..i
        loop
              
            -- printing *
            dbms_output.put('*');
end loop;
  
        -- for new line
        dbms_output.new_line;
        end loop;
        end;
  
        --Program End

Output:

*
**
***
****
*****
******
*******


This article is attributed to GeeksforGeeks.org

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter