Skip to content
Related Articles

Related Articles

Print Patterns in PL/SQL
  • Difficulty Level : Basic
  • Last Updated : 26 Feb, 2021

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

Input : 3
Output :
*
**
***

Input : 7
Output :
*
**
***
****
*****
******
*******

 

C




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
      DBMS_OUTPUT.PUT('*') ; -- printing *
    END LOOP;
    DBMS_OUTPUT.NEW_LINE; -- for new line
  END LOOP;
END;
--Program End

Output: 
 

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

 

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :