Floyd's triangle in PL/SQL Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Prerequisite - PL/SQL introduction In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations. Floyd's triangle is a right-angled triangular array of natural numbers. It is defined by filling the rows of the triangle with consecutive numbers, starting with a 1 in the top left corner. Given a range of number and the task is to form Floyd's triangle. Examples: Input: 1-29 Output: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Below is the required implementation: SQL --floyd's triangle in PL/SQL DECLARE --num, var_num variable declare --num assign 1 num NUMBER := 1; var_num VARCHAR2(200); BEGIN --loop from 1 to 16 FOR i IN 1..16 LOOP FOR j IN 1..i LOOP var_num := var_num ||' ' ||num; num := num + 1; exit WHEN num = 16; END LOOP; --result print dbms_output.Put_line(var_num); exit WHEN num = 16; var_num := NULL; END LOOP; --end loop END; --end program Output: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Comment More infoAdvertise with us Next Article Reverse a string in PL/SQL J jit_t Follow Improve Article Tags : PL/SQL SQL-PL/SQL Similar Reads Reverse a string in PL/SQL Prerequisite - PL/SQL introduction In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations. Given a string, the task is to reverse a string using P 1 min read Reverse a string in PL/SQL Prerequisite - PL/SQL introduction In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations. Given a string, the task is to reverse a string using P 1 min read How to Declare a Variable in PL/SQL? Declaring variables in PL/SQL is a fundamental step towards building powerful and efficient database applications. Variables act as placeholders for data which enable us to manipulate and store information within our PL/SQL programs. Here, we will explore various methods of declaring variables in PL 5 min read Centered triangular number in PL/SQL Prerequisite - PL/SQL introduction In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations. Given n and task is to find nth centered triangular num 2 min read Centered triangular number in PL/SQL Prerequisite - PL/SQL introduction In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations. Given n and task is to find nth centered triangular num 2 min read PL/SQL Tutorial Explore this PL/SQL tutorial to effortlessly learn PL/SQL â It is perfect for beginners and experienced ones. Whether you're new to it or diving deep, this interactive guide simplifies database programming.Learn hands-on with practical examples, making your journey fun and effective. Learn PL/SQL's 8 min read Like