PL/SQL Program to Print Patterns

Here you will get plsql programs to print patterns of stars, numbers and alphabets.

Pattern 1:

Pattern 2:

Pattern 3:

Pattern 4:

Pattern 5:

Pattern 6:

Pattern 7:

Comment below if you need any other pattern. I will try to add it here.

16 thoughts on “PL/SQL Program to Print Patterns

    1. akash ithape

      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;
      /

      Reply
        1. ddl

          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;
          /

          Reply
    2. Amol

      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:
      /

      Reply
  1. ravi

    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;
    /

    Reply
  2. SUMA

    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

    Reply
    1. Divya Gupta

      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;

      Reply
  3. Sonu

    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

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.