- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Floyd's triangle in PL/SQL
PL/SQL is a combination of SQL along with the procedural features of programming languages
FLOYD’s triangle − it is a triangle formed by natural numbers. It is the triangle formed by filling numbers in rows starting from 1 at the top-left corner. It is a right-angled triangle i.e. the count of numbers in each row is the same as the row number.
In this problem, we are given a natural number N. Our task is to create Floyd’s triangle in PL/SQL.
Let’s take an example to understand the problem
Input: 16 Output: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
A solution to the problem is by looping till the count is smaller than N. Keeping a counter for the number of rows, we will increment the count after each row’s count is completed. And for each count, we will fill numbers equal to the row count. As PL/SQL is also a sort of programming language it allows us to perform such tasks.
Program to illustrate the working of our solution
DECLARE n NUMBER := 1; prntVal VARCHAR2(200); BEGIN FOR i IN 1..22 LOOP FOR j IN 1..i LOOP prntVal := prntVal ||' ' ||n; n := n + 1; exit WHEN n = 16; END LOOP; dbms_output.Put_line(prntVal); exit WHEN n = 16; prntVal := NULL; END LOOP; END;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
- Program to print Reverse Floyd’s triangle in C
- Java program to generate and print Floyd’s triangle
- Find the area and perimeter of right triangle in PL/SQL
- Difference between SQL and PL/SQL
- What is PL/SQL?
- How to print Floyd’s triangle (of integers) using C program?
- Difference Between T-SQL and PL-SQL
- Reverse a Number in PL/SQL
- Block of PL/SQL in Oracle DBMS
- Print pyramid of tutorialspoint in PL/SQL
- Program for Fibonacci numbers in PL/SQL
- Explain the PL/SQL Engine in DBMS
- How to capture Oracle errors in PL/SQL?
- Database Wars: MSSQL Server, Oracle PL/SQL and MySQL
- How to Reverse a String in PL/SQL using C++