Write a PL/SQL program to print reverse pyramid - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Thursday, October 5, 2017

Write a PL/SQL program to print reverse pyramid

Print Reverse Pyramid Pattern

Program:

DECLARE
PROCEDURE pyramid(n NUMBER)
IS
star VARCHAR2(1) := '*';
chk NUMBER := n;
sp NUMBER := 0;
BEGIN

LOOP
FOR i IN 1 .. chk
LOOP
dbms_output.put(star);
END LOOP;
sp := sp+ 1;
dbms_output.new_line;
IF chk > 1 THEN
FOR j IN 1 .. sp
LOOP
dbms_output.put(' ');
END LOOP;
END IF;
IF chk != 2 THEN
chk := chk - 2;
ELSIF chk = 2 THEN
chk := 1;
END IF;
EXIT WHEN chk < 1;
END LOOP;

END;

BEGIN
pyramid(8);
END;

Output:
********
******
****
**
*

No comments:

Post a Comment