top of page

Printing stars in PLSQL [FUN]

  • Writer: Rumesh Aponso (RMAX)
    Rumesh Aponso (RMAX)
  • Nov 7, 2024
  • 1 min read

Updated: Nov 22, 2024

declare
   lines_    NUMBER;
   blanks_   NUMBER;
   stars_    NUMBER;
begin
   lines_ := 5;
  
   FOR i_ IN 1..lines_ LOOP
      blanks_ := lines_ - i_;
      stars_  := (2 * i_) - 1;
     
      FOR j_ IN 1..blanks_ LOOP
         Dbms_Output.Put(' ');
      END LOOP;
     
      FOR j_ IN 1..stars_ LOOP
         Dbms_Output.Put('*');
      END LOOP;
     
      Dbms_Output.Put_Line('');
   END LOOP;
  
   -- Test statements here
   --dbms_output.put_line('  *');   -- 3 - x = 2
   --dbms_output.put_line(' ***');
   --dbms_output.put_line('*****');
end;

ree

Comments


Copyright © 2025 RMAXOneNote

  • Online CV
  • LinkedIn
  • Youtube
  • GitHub
  • Blogger
bottom of page